留言
SELECT aa.月份,@curVal := @curVal + aa.monty as sum_money FROM(
SELECT month(销售时间) as 月份,SUM(a.销售数量*b.产品单价) as monty
from 销售明细 a,产品明细 b
where a.`产品ID`=b.`产品ID` and year(a.销售时间)='2020'
GROUP BY month(销售时间)
) aa,(select @curVal:=0) bb
他要求的是每月累加的值
select CONVERT(varchar(2), 日期, 103) as 月份,sum(销售额) from 表 group by CONVERT(varchar(2), 日期, 103)