首页 > 代码库 > oracle 中 group by 加强

oracle 中 group by 加强

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

 

 1 SQL> select deptno,job,sum(sal) 2   2  from emp 3   3   group by rollup(deptno,job); 4   5 DEPTNO JOB         SUM(SAL) 6 ------ --------- ---------- 7                        2000 8                        2000 9     10 CLERK           140010     10 MANAGER         245011     10 PRESIDENT       500012     10                 885013     20 CLERK            80014     20 ANALYST         300015     20 MANAGER         297516     20                 677517     30 CLERK            95018     30 MANAGER         285019     30 SALESMAN        560020     30                 940021                       2702522  23 15 rows selected

 

oracle 中 group by 加强