SELECT HOUR(e.time)as Hour,FLOOR(MINUTE(e.time)/30) as M, COUNT(*) as Count
FROM error_log e
WHERE e.date = '2017-09-02'
GROUP BY FLOOR(MINUTE(e.time)/30),HOUR(e.time)
ORDER BY Hour(e.time);
floor函数是mysql 的向下取整函数 如 floor(1.2) = 1
以下是运行结果:
————————————————
版权声明:本文为CSDN博主「刘宇LY」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_28766327/article/details/77864672