oracle sum over函数
2017-05-09 00:00
411 查看
规则
sum(…) over( ),对所有行求和sum(…) over( order by … ), 连续求和
sum(…) over( partition by… ),同组内所行求和
sum(…) over( partition by… order by … ),同第1点中的排序求和原理,只是范围限制在组内
sum(sal) over (partition by deptno order by ename) 按部门“连续”求总和
sum(sal) over (partition by deptno) 按部门求总和
sum(sal) over (order by deptno,ename) 不按部门“连续”求总和
sum(sal) over () 不按部门,求所有员工总和,效果等同于sum(sal)。
select deptno,
ename,
sal,
sum(sal) over(partition by deptno order by ename) 部门连续求和, --各部门的薪水"连续"求和
sum(sal) over(partition by deptno) 部门总和, -- 部门统计的总和,同一部门总和不变
100 * round(sal / sum(sal) over(partition by deptno), 4) "部门份额(%)",
sum(sal) over(order by deptno, ename) 连续求和, --所有部门的薪水"连续"求和
sum(sal) over() 总和, -- 此处sum(sal) over () 等同于sum(sal),所有员工的薪水总和
100 * round(sal / sum(sal) over(), 4) "总份额(%)"
from emp
![](https://static.oschina.net/uploads/space/2017/0509/185256_6jOv_3337579.png)
相关文章推荐
- oracle中decode()\sum()\over()函数解决实际问题的应用
- oracle分析函数系列之sum(col1) over(partition by col2 order by col3):实现分组汇总或递增汇总
- ORACLE的 SUM()OVER()函数的使用1
- oracle分析函数系列之sum(col1) over(partition by col2 order by col3):实现分组汇总或递增汇总
- oracle sum()over函数的使用
- Oracle-分析函数之sum(...) over(...)
- oracle分析函数sum/ration_to_report(column) over (partition by column order by column)
- oracle分析函数系列之sum(col1) over(partition by col2 order by col3):实现分组汇总或递增汇总
- oracle sum()over函数的使用
- Oracle-分析函数之sum(...) over(...)
- oracle sum()over函数的使用
- ORACLE SUM over分析函数
- oracle sum()over函数的使用
- oracle分析函数系列之sum(col1) over(partition by col2 order by col3):实现分组汇总或递增汇总
- oracle累积求和分析函数sum over的使用
- Oracle-分析函数之sum(...) over(...)
- oracle中的over函数的用法
- Oracle 语法之 OVER (PARTITION BY ..) 及开窗函数
- Oracle select --分析函数over()
- oracle over函数详解(转帖)