WHEN datepart(hour,uptime) IN (2,3) THEN 2
WHEN datepart(hour,uptime) IN (4,5) THEN 3
WHEN datepart(hour,uptime) IN (6,7) THEN 4
WHEN datepart(hour,uptime) IN (8,9) THEN 5
WHEN datepart(hour,uptime) IN (10,11) THEN 6
WHEN datepart(hour,uptime) IN (12,13) THEN 7
WHEN datepart(hour,uptime) IN (14,15) THEN 8
WHEN datepart(hour,uptime) IN (16,17) THEN 9
WHEN datepart(hour,uptime) IN (18,19) THEN 10
WHEN datepart(hour,uptime) IN (20,21) THEN 11
WHEN datepart(hour,uptime) IN (22,23) THEN 12
ELSE 0 END AS sq
FROM bak_dircost0901
-------------------------------
uptime sq
2014/8/19 9:20:59 5
2014/8/22 20:31:20 11
2014/8/22 20:33:08 11
2014/8/26 13:48:01 7
2014/8/27 16:10:45 9
SELECT DATE_FORMAT(time,'%Y-%m-%d') as day, sum(case when amount>0 then amount when amount=0 then 0 end) as amount1from table where time>='2014-11-01' group by day
我没有测试。time表示日期,amount表示数量。查询11月后每天成交数量
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)