say I have this:
select money from somewhere
I want now another column called accumulatedMoney which is going to be = to accumulatedMoney of previous row + money of current row
Ex:
m = 2, am = 2
m = 3, am = 5
m = 3, am = 8
...
What can I do to achieve this?
Thanks
In any database, you can do this with a correlated subquery:
In any database, you can also do this as a join and group by:
In databases that support cumulative sums, you can do it as:
(SQL Server 2012 and Oracle support this.)