首页 > 数据库技术 > 详细

oracle 组函数

时间:2017-04-16 09:28:41      阅读:221      评论:0      收藏:0      [点我收藏+]

技术分享技术分享

 

技术分享

技术分享

 

 

group by的增强
SQL> select deptno,job,sum(sal) from emp group by deptno,job
SQL> +
SQL> select deptno,sum(sal) from emp group by deptno
SQL> +
SQL> select sum(sal) from emp
SQL> 
SQL> ===
SQL> 
SQL> select deptno,job,sum(sal) from emp group by rollup(deptno,job);
SQL> 
SQL> 抽象
SQL> group by rollup(a,b)
SQL> ==
SQL> group by a,b
SQL> +
SQL> group by a
SQL> +
SQL> group by null
SQL> 
SQL> */
SQL> select deptno,job,sum(sal) from emp group by rollup(deptno,job);

 

 

报表

break on deptno skip 2
SQL> /

    DEPTNO JOB         SUM(SAL)                                                                                                                                                                         
---------- --------- ----------                                                                                                                                                                         
        10 CLERK           1300                                                                                                                                                                         
           MANAGER         2450                                                                                                                                                                         
           PRESIDENT       5000                                                                                                                                                                         
                           8750                                                                                                                                                                         
                                                                                                                                                                                                        
                                                                                                                                                                                                        
        20 CLERK           1900                                                                                                                                                                         
           ANALYST         6000                                                                                                                                                                         
           MANAGER         2975                                                                                                                                                                         
                          10875                                                                                                                                                                         
                                                                                                                                                                                                        

    DEPTNO JOB         SUM(SAL)                                                                                                                                                                         
---------- --------- ----------                                                                                                                                                                         
                                                                                                                                                                                                        
        30 CLERK            950                                                                                                                                                                         
           MANAGER         2850                                                                                                                                                                         
           SALESMAN        5600                                                                                                                                                                         
                           9400                                                                                                                                                                         
                                                                                                                                                                                                        
                                                                                                                                                                                                        
                          29025                                                                                                                                                                         
                                                                                                                                                                                                        
                                                                                                                                                                                                        

 

oracle 组函数

原文:http://www.cnblogs.com/jycjy/p/6717721.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!