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 department_id, --> department_id --> 1개
ROLLUP(job_id), --> job_id, () --> 2개 => 1*2*2=4개의 group by 절이 생성된다고 생각
CUBE(manager_id); --> manager_id, () --> 2개
==> GROUP BY department_id, job_id, manager_id
+ GROUP BY department_id, job_id, () ==> department_id, job_id
+ GROUP BY department_id, (), manager_id ==> department_id, manager_id
+ GROUP BY department_id, (), () ==> department_id
'Oracle > SQL Fundamentals II' 카테고리의 다른 글
14일차 # dbtimezone vs. sessiontimezone (0) | 2012.04.23 |
---|---|
14일차 # 5-4: Time Zone Setting (0) | 2012.04.23 |
14일차 # 4-21: Concatenated Groupings (0) | 2012.04.23 |
14일차 # 4-17: Composite Columns (0) | 2012.04.23 |
14일차 # 4-11: Grouping 함수 (0) | 2012.04.23 |