0

I would like to sum the values from different rows in SQL example

|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|

Basically is sum the values by month to 201412.

Any idea?

Jonny
  • 2,509
  • 23
  • 42

1 Answers1

0
SELECT t1.Period, SUM(t2.AMOUNT)
FROM table as t1
  JOIN table as t2
  ON t1.Period >= t2.Period
GROUP BY t1.Period
Jonny
  • 2,509
  • 23
  • 42