here i will show you how you can calculate cumulative sum
RowId
Amount
1
100
2
200
3
300
4
4000
Then you can get cumulative sum from the following query:
Select Rowid, amount , ( select max(amount ) + amount from table where table.rowid < t1.rowid) as cumulativesum
From table t1