SELECT last_name, salary, department_id
FROM employees
WHERE salary IN (SELECT MIN(salary)
FROM employees
GROUP BY department_id);
↓ ↓
SELECT last_name, salary, department_id
FROM employees
WHERE salary IN ( 7000,
17000,
6000,
8300,
2500,
8600,
4200,
4400);
* deptno IN (10, 20, 30) === (deptno = 10) OR (deptno = 20) OR (deptno = 30)
deptno NOT IN (10, 20, 30) === (deptno <> 10) AND (deptno <> 20) AND (deptno <> 30)
cf.) 부서별 최소 급여 사원
SQL> SELECT last_name, salary, department_id
2 FROM employees
3 WHERE (department_id, salary) IN (SELECT department_id, MIN(salary)
4 FROM employees
5 GROUP BY department_id);
'Oracle > SQL Fundamentals I' 카테고리의 다른 글
9일차 # Pseudocolumn (0) | 2012.04.16 |
---|---|
9일차 # 6-16: ANY, ALL (0) | 2012.04.16 |
9일차 # 6-13:single-row 서브쿼리의 리턴 값이 null일 경우 (0) | 2012.04.16 |
9일차 # 6-12: Multiple-row subquery (0) | 2012.04.16 |
9일차 # 6-11: Having clause (0) | 2012.04.16 |