Mysql 假如我有一个表,有字段day,money,day记录我攒钱的第几天,money记录我当天攒的钱数,请写一个查询,返回我攒钱的天数,和这一天之前(包含这一天)一共攒的钱数
SELECT
day,
money,
(@cumulative_money := @cumulative_money + money) AS cumulative_money
FROM
your_table_name,
(SELECT @cumulative_money := 0) AS var_init
ORDER BY
day;
标签:money,cumulative,累加,按序,MySQL,查询,day
From: https://www.cnblogs.com/jsom/p/17567994.html