SqlServer 根据时间统计数据展示图表

Posted che109

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SqlServer 根据时间统计数据展示图表相关的知识,希望对你有一定的参考价值。

 

  --本年
  select   m as [Date],sum(case when datepart(month,CreateDateTime)=m then 1 else 0 end )as [Count]  
   from [dbo].CrmCustomer c,
   (select 1 m 
    union all select 2  
    union all select 3 
    union all select 4
    union all select 5 
    union all select 6  
    union all select 7 
    union all select 8  
    union all select 9  
    union all select 10  
    union all select 11  
    union all select 12) aa where  2018= year(CreateDateTime) group by   m;
    
    
    --本月
    select DATEPART(day,CreateDateTime) as [Date],COUNT(id) AS [Count] from [dbo].CrmCustomer 
    WHERE   DATEPART(mm, CreateDateTime) = DATEPART(mm, GETDATE()) and DATEPART(yy, CreateDateTime) = DATEPART(yy, GETDATE()) 
    group by DATEPART(day,CreateDateTime)
           
--本周 select convert(nvarchar(10),CreateDateTime,120) AS [Date],COUNT(id) as [Count] from [dbo].CrmCustomer where datediff(week, CreateDateTime ,getdate())=0 group by convert(nvarchar(10),CreateDateTime,120)

 


以上是关于SqlServer 根据时间统计数据展示图表的主要内容,如果未能解决你的问题,请参考以下文章

sqlserver怎么查看表的内容

Grafana配置SingleStat图表信息

数据可视化中数据展示效果,基于highcharts的图表数据展示

微信小程序之使用echarts图表展示OneNet温度数据

SQLServer 2014 内存优化表

FineReport如何操作离线点地图