Get Cumulative sum in specific column of table.

By Super Man

here i will show how to get cumulative sum in table.

lets take sample data


ID       Amount1  Amount2
1         15
2         30
3         45
4         60


here amount2 is empty and we want cumulative sum in amount2 based on column amount1 , then you can use this query

update table_name as t1
set amount2 = amount1 + ( select max(amount2) from table_name where id < t1.id )

Get Cumulative sum in specific column of table.  (1571 Views)