In addition to the subtotals generated by the
SELECT SUM (sal) tsal, job, deptno
FROM emp
GROUP BY CUBE (job, deptno)
ORDER BY job, deptno,job;
7000 ANALYST 50
7000 ANALYST
1450 CLERK 30
9600 CLERK 50
11050 CLERK
4350 MANAGER 30
4350 MANAGER
5000 SALESMAN 10
10250 SALESMAN 30
2000 SALESMAN 40
17250 SALESMAN
5000 10
16050 30
2000 40
16600 50
39650
ROLLUP
extension, the CUBE
extension will generate subtotals for all combinations of the dimensions specified. If "n" is the number of columns listed in the CUBE
, there will be 2n subtotal combinations.SELECT SUM (sal) tsal, job, deptno
FROM emp
GROUP BY CUBE (job, deptno)
ORDER BY job, deptno,job;
7000 ANALYST 50
7000 ANALYST
1450 CLERK 30
9600 CLERK 50
11050 CLERK
4350 MANAGER 30
4350 MANAGER
5000 SALESMAN 10
10250 SALESMAN 30
2000 SALESMAN 40
17250 SALESMAN
5000 10
16050 30
2000 40
16600 50
39650