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
答案 0 :(得分:4)
sql代码:
SELECT
aid,year,
salary=(SELECT SUM(slalry) FROM slalry WHERE year<=A.year)
FROM slalry AS A;
答案 1 :(得分:0)
您无法准确获得指定的结果,因为每年不会有唯一的[援助]值。但是,省略此列,您可以使用:
SELECT year, SUM(slalry)
FROM slalry
GROUP BY year