- Group By 절의 Rollup, Cube, Grouping Sets 에서 사용
- 여러 컬럼을 하나의 컬럼처럼 여기도록
- 괄호로 여러 컬럼을 묶음
SELECT department_id, job_id, manager_id,
SUM(salary),
grouping(department_id) as GRP_D,
grouping(job_id) as GRP_J,
grouping(manager_id) as GRP_M
FROM employees
GROUP BY ROLLUP( department_id,(job_id, manager_id));
cf.) composite column이 아닌 경우
SELECT department_id, job_id, manager_id,
SUM(salary),
grouping(department_id) as GRP_D,
grouping(job_id) as GRP_J,
grouping(manager_id) as GRP_M
FROM employees
GROUP BY ROLLUP( department_id, job_id, manager_id);
'Oracle > SQL Fundamentals II' 카테고리의 다른 글
14일차 # 4-22: 예제 (0) | 2012.04.23 |
---|---|
14일차 # 4-21: Concatenated Groupings (0) | 2012.04.23 |
14일차 # 4-11: Grouping 함수 (0) | 2012.04.23 |
14일차 # 4-14: grouping sets를 이용하여 rollup, cube 구현 (0) | 2012.04.23 |
14일차 # 4-13 Grouping Sets (0) | 2012.04.23 |