MySQL表slalry:

aid    year    slalry
1      2000    1000
2      2001    2000
3      2002    3000
4      2003    4000

如何得到结果:
aid    year    slalry
1      2000    1000
2      2001    3000
3      2002    6000
4      2003    10000

最佳答案

sql代码:

   SELECT
        aid,year,
        salary=(SELECT SUM(slalry) FROM slalry WHERE year<=A.year)
    FROM slalry AS A;

关于mysql - 如何使用SQL查询逐年获取总薪水?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/1062982/

10-11 03:56