oracle 中 group by 加强

时间:2021-02-02 03:05:50

group by rollup(a,b)
 =
 group by a,b
 +
 group by a
 +
 group by null

 SQL> select deptno,job,sum(sal)
2 from emp
3 group by rollup(deptno,job); DEPTNO JOB SUM(SAL)
------ --------- ----------
2000
2000
10 CLERK 1400
10 MANAGER 2450
10 PRESIDENT 5000
10 8850
20 CLERK 800
20 ANALYST 3000
20 MANAGER 2975
20 6775
30 CLERK 950
30 MANAGER 2850
30 SALESMAN 5600
30 9400
27025 15 rows selected