I have a table like this
I want to replace null
values in P by logic
present value of column P = present value of column S + previous value of column P.
Expected output:
Thanks in advance
I have a table like this
I want to replace null
values in P by logic
present value of column P = present value of column S + previous value of column P.
Expected output:
Thanks in advance
We can achieve this by using variables in mysql
SELECT
pur.Id, pur.s,
(@b := @b + pur.s) - 10 AS p
FROM
(SELECT @b := 0.0) AS dummy
CROSS JOIN
purchase AS pur
ORDER BY
Id ;