SELECT SUBSTRING(replace(replace(replace(CONVERT(varchar, ScanTime, 120 ),'-',''),' ',''),':',''),9,3) ctime, count(1) num FROM [eschool_1].[dbo].kg_Kaoqin group by SUBSTRING(replace(replace(replace(CONVERT(varchar, ScanTime, 120 ),'-',''),' ',''),':',''),9,3) order by SUBSTRING(replace(replace(replace(CONVERT(varchar, ScanTime, 120 ),'-',''),' ',''),':',''),9,3)