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