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)

 

posted @ 2017-03-11 16:59  shiningrise  阅读(792)  评论(0编辑  收藏  举报
// 侧边栏目录 // https://blog-static.cnblogs.com/files/douzujun/marvin.nav.my1502.css