- 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);

+ Recent posts