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

oracle 中 group by 加强

 =
 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           1400
10     10 MANAGER         2450
11     10 PRESIDENT       5000
12     10                 8850
13     20 CLERK            800
14     20 ANALYST         3000
15     20 MANAGER         2975
16     20                 6775
17     30 CLERK            950
18     30 MANAGER         2850
19     30 SALESMAN        5600
20     30                 9400
21                       27025
22  
23 15 rows selected

oracle 中 group by 加强