MySQL 按日累加求销量 按月累加求销量
作者:admin 日期:2018-05-28
按日累加求销量
复制内容到剪贴板 程序代码
Select
a.id,
a.product,
a.sale_date,
a.num ,
(
Select
sum(num)
FROM
t_sale_stats b
Where
b.id <= a.id
AND b.product = '产品名称'
AND b.sale_date >= '2015-03-01'
AND b.sale_date <= '2015-03-05'
) cum_num
FROM
t_sale_stats a
Where
a.sale_date >= '2015-03-01'
AND a.sale_date <= '2015-03-05'
AND a.product = '产品名称'
ORDER BY