我需要在mysql中使用Time Wise Sales Report,我得到报告
Time Amount
19:00:00 2
20:00:00 5
21:00:00 0
22:00:00 0
23:00:00 14
但我需要金额的总和
Time Amount
19:00:00 2
20:00:00 5
21:00:00 5
22:00:00 5
23:00:00 14
这是我的查询
SELECT concat(MID(date_of_call, 12, 2),':00:00') TimeIntervel,COUNT(*) TotalEntries,date_format(date_of_call,'%d/%m/%Y') FROM ICC_MM_setup_suply
WHERE DATE_FORMAT(date_of_call,'%d/%m/%Y')='31/01/2017'
GROUP BY concat(MID(date_of_call, 12, 2),':00:00')
答案 0 :(得分:0)
您可以使用用户变量:
set @lastval := 0;
select
time,
@lastval := if(Amount = 0, @lastval, Amount) Amount
from t
order by time;