mysqlgroupby
一张表。
数据的主要结构:
id
num
create_time
我现在写的有问题,只能显示有数据的日期。
SELECT DATE_FORMAT(create_time,'%Y-%m-%d') AS day,
(CASE WHEN COUNT(num)='0' THEN 0 ELSE COUNT(num) END) AS counts
FROM infos
WHERE DATE_FORMAT(create_time,'%Y-%m-%d') BETWEEN '2015-05-01' AND '2015-05-30' GROUP BY day
要求:
每个时间点数据都要显示出来,没有数据的则为 0 .