oracle 组函数

Posted 求知若饥,虚心若愚。

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了oracle 组函数相关的知识,希望对你有一定的参考价值。

 

 

 完整的select **  from **  where  ** group by ** having ** order by **;

select job_id,sum(salary) payroll 
from employees
where job_id not like \'%REP%\'
group by job_id
having sum(salary)>1300
order by sum(salary)

  

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 组函数的主要内容,如果未能解决你的问题,请参考以下文章

sql Oracle代码片段

markdown 岩组代码片段

如何在 Toad for Oracle 中使用自定义代码片段?

oracle 组函数 max min等

python使用上下文对代码片段进行计时,非装饰器

Oracle函数组的使用