I have table with two columns namely cumulative_sum and absolute. But I only have cumulative value. I would like to calculate absolute value.
Cumulative Value
12
19
32
41
Expected Absolute Value
12
7
13
9
I have try a query like this. I just need to update @absvalue to cum every time query update.
set @absvalue := 0;
update pdb_tint_result set abs = (cum - @absvalue)
where user_id='P6'
order by date;
Can you please guide me?
I saw calculating cumulative sum here I try to make it work for calculation Abs value.