SELECT year_month_val, xun, flux, ROUND(@temp:=@temp+flux,4) AS yearVal FROM (SELECT year_month_val, xun, SUM(flux)flux FROM wrs_muw_plan WHERE manage_id = 568 AND year_month_val BETWEEN '2020-09-01' AND '2021-09-01' GROUP BY year_month_val, xun ORDER BY year_month_val ASC, field(xun,'上旬','中旬','下旬'))a,(SELECT @temp:=0)T