Employee names and salaries # queries and the same sector Zlotkey
SELECT last_name,salary
FROM employees
WHERE department_id=(
SELECT department_id
FROM employees
WHERE last_name='Zlotkey'
);
# Query higher wages than the company average wage of employees employee number, name and salary
SELECT employee_id,last_name,salary
FROM employees
WHERE salary>(
SELECT AVG(salary)
FROM employees
);
# Query various departments in this sector wages higher than the average salary of the employee number, name and salary
Note: Connect Employees table and the average payroll, rescreening
SELECT employee_id,last_name,salary
FROM (
SELECT AVG(salary) s,department_id
FROM employees
GROUP BY department_id
) a
INNER JOIN employees e
ON a.department_id=e.department_id
WHERE e.salary>s;
# Query name contains the letters u and staff employees of the same department employee number and name
to the query contains u id department employees, as in the case then check id
SELECT employee_id,last_name
FROM employees
WHERE department_id IN(
SELECT DISTINCT department_id
FROM employees
WHERE last_name LIKE '%u%'
);
# Location_id sector inquiry in 1700 for the department's employees number of employees
Note first check location_id department number is equal to 1700, the number of employees in the query
SELECT employee_id
FROM employees e
WHERE e.`department_id` IN(
SELECT department_id
FROM departments d
WHERE d.`location_id`=1700
)
# Query manager is K_ing employee names and salaries, there are two K_ing
SELECT last_name,salary
FROM employees e
WHERE e.manager_id IN(
SELECT `employee_id`
FROM employees m
WHERE `last_name`='K_ing'
);
# Query the name of the highest wages, the requirements first_ame and last_name displayed as a column called the family name. Name
# surnamed special characters that require quotes
SELECT CONCAT(first_name,last_name) '姓.名'
FROM employees e
WHERE e.salary=(
SELECT MAX(salary)
FROM employees
);