MSSQL查询统计

来源:互联网 发布:网络十大神曲污曲 编辑:程序博客网 时间:2024/05/22 03:28
 select day(CreatedAt) 日 ,COUNT(Name) count from  [Ruiec_NewCloud_BlogCenter].[dbo].[T_Blog_Demand] 
  where CreatedAt between '2017-06-01' and '2017-07-01'
 group by year(CreatedAt),month(CreatedAt) ,day(CreatedAt) /*日统计*/


  select month(CreatedAt) 月 ,COUNT(Name) count from  [Ruiec_NewCloud_BlogCenter].[dbo].[T_Blog_Demand] 
  where CreatedAt between '2017-01-01' and '2017-12-31'
 group by month(CreatedAt) ,year(CreatedAt)  /*月统计*/




 select sum(Name) as count,datepart(week,CreatedAt) 周 from 
[Ruiec_NewCloud_BlogCenter].[dbo].[T_Blog_Demand]  where CreatedAt between '2017-06-01' and '2017-07-01'
group by datepart(week,CreatedAt)  /*周统计*/




  select  month(CreatedAt) 月 ,day(CreatedAt),COUNT(Name) count from  [Ruiec_NewCloud_BlogCenter].[dbo].[T_Blog_Demand] 
  where CreatedAt between '2017-06-01' and '2017-07-01'
 group by month(CreatedAt) ,day(CreatedAt)
原创粉丝点击