I have a table with two columns, namely cumulative_sum and absolute. But I have only cumulative value. I would like to calculate the absolute value.
Cumulative value
12
19
32
41
Expected Absolute Value
12
7
13
9
I tried such a request. I just need to update @absvalue to the end each time the request is updated.
set @absvalue := 0;
update pdb_tint_result set abs = (cum - @absvalue)
where user_id='P6'
order by date;
Can you guide me?
I saw the calculation of the total amount here.
I'm trying to get it to work to calculate the value of Abs.
source
share