已经知道原表
year salary
------------------ ---------------------
2000 1000
2001 2000
2002 3000
2003 4000
显示查询结果
year salary
------------------ ---------------------
2000 1000
2001 3000
2002 6000
2003 10000

即salary为以前年的工资的和;

我这里提供的答案有两种
第一种:
select b.year,sum(a.salary)
from salary a,salary b
where a.year<=b.year group by b.year
order by b.year;

其中salary 为工资表

第二种:
select s1.year "year",(select sum(s2.salary) from salary s2 where s2.year<=s1.year) "salary" from salary s1;

相关文章:

  • 2021-10-14
  • 2021-04-04
  • 2022-02-04
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2021-04-26
  • 2021-11-18
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-06-20
  • 2021-10-11
  • 2021-12-16
  • 2022-12-23
  • 2021-10-26
相关资源
相似解决方案