select T.timehour,count(T.es_out_in_id) as number from
(
select o.es_out_in_id, DATE_FORMAT(create_time,'%H') as timehour from t_tm_eq_scan_record as o
) as T
group by T.timehour
order by timehour asc
https://blog.csdn.net/hackersmile/article/details/103716521