按2小时段统计
select * from (SELECT FLOOR(HOUR(dateTimeColumn) / 2) * 2 as hour, count(id) as num FROM tableName group by hour ) tmp order by num
按1小时段统计
select * from (SELECT HOUR(dateTimeColumn) as hour, count(id) as num FROM tableName group by hour ) tmp order by num
标签:count,tmp,HOUR,hour,SQL,num,时间段,MySQL From: https://www.cnblogs.com/101key/p/17854630.html