select new.time click_hour, new.count click_cnt from( select date_format(click_time, '%H') time, row_number()over(order by sum(trace_id) desc) as rk, count(trace_id) count from user_ad_click_time group by date_format(click_time, '%H') ) new where new.rk = 1