How can I make a cumulative sum of mysql column and group by month year here is my table "saving"
id date value
1 01/01/2018 10
2 01/12/2018 5
3 02/03/2018 6
4 02/23/2018 4
I try this query
SET @SumVariable:=0;
select CONCAT(LEFT(monthname(date),3),'-', year(date)) as month
,sum(value)
,(@SumVariable := @SumVariable + sum(value)) AS total
FROM saving
GROUP BY year(date), month(date) LIMIT 50
The query returns
month value
jan-2018 15
feb-2018 10
It's not cumulative the sum, I need the output to be as follow
month total
jan-2018 15
feb-2018 25