1. 程式人生 > >mysql當前行的值累加上一行的值

mysql當前行的值累加上一行的值

SELECT d.*,  @total :[email protected] + addition AS total FROM (SELECT TRUNCATE(day_id,0) as date,sum(new_user) AS addition,sum(active_user) AS active FROM  (SELECT @total := 0) t, `dmp_new_active_users_stat` d  WHERE TRUNCATE (day_id, 0) >= 20181211 AND TRUNCATE (day_id
, 0) <= 20181319 GROUP BY date ORDER BY date ) d