Oracle sql技巧--分组统计

select deptno,
       ename,
       sal,
       sum(sal) over(partition by deptno order by deptno desc, sal desc) dept_sum, --组内合计
       sum(sal) over(order by deptno desc, sal desc) total_sum, --对所有数据依次累计
       round(sal / sum(sal) over(partition by deptno), 2) as empRatio --计算所占比例
  from emp;

参考链接:https://blog.csdn.net/an342647823/article/details/9039339

https://blog.csdn.net/javaalpha/article/details/52119415

原文链接:https://wenku.baidu.com/view/afcc6984d4d8d15abe234ed7.html

猜你喜欢

转载自blog.csdn.net/u010999809/article/details/79904517