我想按日期提供一些日常报告。 我希望这些数据每天都在增加。
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
这是第一个代码:
SELECT Date, SUM(number) AS qty FROM calc GROUP BY Date
如何显示“QP”如果实际上我不需要显示“数量”字段(自动计数)只显示日期和QP但它仍然可以计数?
答案 0 :(得分:1)
SET @r := 0;
SELECT date, @sum := SUM(number) AS qty, @r := @r + @sum AS qp
FROM calc
GROUP BY
date
答案 1 :(得分:0)
此示例将帮助您确定: