Cumulative sum over days
问题 I have a MySQL table like the following: date count 2010-01-01 5 2010-01-02 6 2010-01-03 7 How can I accumulate the sum of each day to the next one? So the result is like: date acum per day 2010-01-01 5 2010-01-02 11 2010-01-03 18 I think i need some kind of for(each date)... but no clue. Just the final query i used following answer from Eric. (thanks). SELECT t1.dia, sum(t2.operacions), sum(t2.amount) FROM (SELECT count(*) operations, sum(amount), date(b.timestamp) dia FROM transactions b