- 컬럼에 대해 임의의 그룹을 지음
- ()
- Union All 로 똑같은 결과를 얻을 수 있으나 보다 효율적임
select deptno, job, sum(sal) from emp
group by rollup(deptno, job);
↓↓
select deptno, job, sum(sal) from emp
group by deptno, job
union all
select deptno, to_char(null), sum(sal) from emp
group by deptno
union all
select to_number(null), to_char(null), sum(sal) from emp
group by ()
order by 1, 2;
'Oracle > SQL Fundamentals II' 카테고리의 다른 글
14일차 # 4-11: Grouping 함수 (0) | 2012.04.23 |
---|---|
14일차 # 4-14: grouping sets를 이용하여 rollup, cube 구현 (0) | 2012.04.23 |
14일차 # 4-9 Cube (0) | 2012.04.23 |
14일차 # 4-7 Rollup (0) | 2012.04.23 |
14일차 # 4장 Rollup, Cube, Grouping Sets (0) | 2012.04.23 |