SELECT HOUR(e.time) as Hour,count(*) as Count
FROM error_log e
WHERE e.date = '2017-09-02'
GROUP BY HOUR(e.time) ORDER BY Hour(e.time);
下面是查询结果截图
在另一篇文章里,我总结了查询每半小时统计一次的方法。Mysql 查询一天中每半小时记录的数量
原文地址:https://blog.csdn.net/qq_28766327/article/details/77856896