select count(distinct id) cnt , substr(time,1,13) hours from mytable a group by substr(time,1,13) order by 2