Given the table:
id date count cumulative_sum
1 2 100
2 1 50
3 1 10
4 2 5
How do I update cumulative_sum
of the rows ordered by date
, id
?
The result should be:
id date count cumulative_sum
2 1 50 50
3 1 10 60
1 2 100 160
4 2 5 165
Is it also possible to update only those rows that need to be recalculated when I insert or update a row?