我的表格如下:
datePickup deliveryStatus count
2015-09-04 16:14:55 1 NULL
2015-09-04 15:52:52 99 NULL
2015-09-04 12:47:55 2 NULL
2015-09-05 06:14:55 99 NULL
2015-09-05 15:52:52 99 NULL
2015-09-05 17:47:55 99 NULL
2015-09-06 02:14:55 1 NULL
2015-09-06 14:52:52 99 NULL
2015-09-06 17:47:55 99 NULL
如果交货状态为99,我希望白天完成交货:
datePickup count
2015-09-04 1
2015-09-05 3
2015-09-06 2
答案 0 :(得分:1)
将GROUP BY
与DATE()
:
SELECT DATE(datePickup), count(*)
FROM yourtable
WHERE deliveryStatus=99
GROUP BY DATE(datePickup);
答案 1 :(得分:0)
尝试DATE_FORMAT
select DATE_FORMAT(datePickup, '%Y-%m-%d'), count(*) where deliveryStatus = 99 group by DATE_FORMAT(datePickup, '%Y-%m-%d')