SQLServer 按日,周统计数据
--按日统计 SELECT CONVERT(VARCHAR(10),日期列,120) AS days,COUNT(1) AS totalCount FROM 表 GROUP BY CONVERT(VARCHAR(10),日期列,120) ORDER BY days --按周统计 select datepart(week, 日期列) AS weekCount, sum(1) AS totalCount from 表 group by datepart(week, 日期列) ORDER BY weekCount
微信扫码查看本文
发表评论