- A cross-product of groupings from each grouping set
* GROUP BY grouping sets (a, b), grouping sets (c, d)
= GROUP BY a, c ┐
+ GROUP BY a, d ├ cross-product of (a, b) and (c, d)
+ GROUP BY b, c │
+ GROUP BY b, d ┘
==> http://goo.gl/a9DJ4
GROUP BY grouping sets(rollup(a, b, c))
==> GROUP BY grouping sets( (a, b, c), (a, b), (a), () )
ex) select deptno, job
from emp
group by rollup(deptno, job)
order by 1, 2;
select deptno, job
from emp
group by grouping sets(rollup(deptno, job))
order by 1, 2;
select deptno, job
from emp
group by grouping sets( (deptno, job), deptno, ())
order by 1, 2;
'Oracle > SQL Fundamentals II' 카테고리의 다른 글
14일차 # 5-4: Time Zone Setting (0) | 2012.04.23 |
---|---|
14일차 # 4-22: 예제 (0) | 2012.04.23 |
14일차 # 4-17: Composite Columns (0) | 2012.04.23 |
14일차 # 4-11: Grouping 함수 (0) | 2012.04.23 |
14일차 # 4-14: grouping sets를 이용하여 rollup, cube 구현 (0) | 2012.04.23 |