问题:对于数字列中的值,计算其累计差。例如:计算DEPTNO 10中工资的累计差。

select a.empno,a.ename,a.sal,
(select case when a.empno=min(b.empno) then sum(b.sal)
else sum(-b.sal)
end
from emp b 
where b.empno<=a.empno
and b.deptno=a.deptno) as rnk
from emp a
where a.deptno=10;

相关文章:

  • 2022-12-23
  • 2021-09-28
  • 2021-11-24
  • 2019-03-07
  • 2021-11-14
  • 2021-11-24
猜你喜欢
  • 2021-08-22
  • 2022-12-23
  • 2021-12-15
  • 2022-12-23
  • 2021-08-27
  • 2021-12-18
  • 2021-12-19
相关资源
相似解决方案