sql按分时段统计

  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)

 

你可能感兴趣的:(sql按分时段统计)