SELECT last_name ,salary
FROM employees
WHERE salary>(
SELECT salary
FROM employees
WHERE last_name='ABEL'
)
#单行子查询
SELECT *
FROM employees
WHERE salary>(
SELECT salary
FROM employees
WHERE employee_id=149
);
SELECT job_id,salary,last_name
FROM employees
WHERE job_id=(
SELECT job_id
FROM employees
WHERE employee_id=141
)
AND salary>(
SELECT salary
FROM employees
WHERE employee_id=143
);
SELECT last_name, job_id, salary
FROM employees
WHERE salary =(
SELECT MIN(salary)
FROM employees
);
SELECT last_name,job_id, MIN(salary)
FROM employees;
SELECT employee_id,manager_id,department_id
FROM employees
WHERE manager_id=(
SELECT manager_id
FROM employees
WHERE employee_id=141
)
AND department_id=(
SELECT department_id
FROM employees
WHERE employee_id=141
)
AND employee_id<>141;
SELECT employee_id,manager_id,department_id
FROM employees
WHERE (manager_id,department_id)=(
SELECT manager_id,department_id
FROM employees
WHERE employee_id=141
)
AND employee_id<>141;
SELECT department_id,MIN(salary)
FROM employees
GROUP BY department_id
HAVING MIN(salary)>(
SELECT MIN(salary)
FROM employees
WHERE department_id=110
);
SELECT employee_id,last_name
FROM employees
WHERE salary >(
SELECT MIN(salary)
FROM employees
GROUP BY department_id
WHERE department_id=110
);