我想在SQL示例
中对来自不同行的值求和|Period | Amount |Sum |
---------------------------
|201401 | 100.00 |100.00 |
|201402 | 200.00 |300.00 |
|201403 | 500.00 |800.00 |
|201404 | 300.00 |1100.00|
|201405 | 50.00 |1150.00|
基本上是按月计算到201412的值。
有什么想法吗?
答案 0 :(得分:0)
SELECT t1.Period, SUM(t2.AMOUNT)
FROM table as t1
JOIN table as t2
ON t1.Period >= t2.Period
GROUP BY t1.Period