making daily report with MySQL
i want to make some daily report which order by date. i want this data can increase every day.
Date qty QP
2010-09-01 10 10
2010-09-02 3 13 (it means result QP from 2010-09-01 accumulate with 2010-09-02)
2010-09-03 8 21
this is the 1st code:
SELECT Date, SUM(number) AS qty FROM calc GROUP BY Date
how do i do to show "QP" if for actually i dont need to show "qty" field(automatic count) just show Date and QP but it still ca开发者_开发技巧n count?
SET @r := 0;
SELECT date, @sum := SUM(number) AS qty, @r := @r + @sum AS qp
FROM calc
GROUP BY
date
This example will help you for sure:
MySQL select "accumulated" column
精彩评论