统计次数

SELECT year(fCreatTime)as 年份,sum (case when fLeiBie='1' then 1 else 0 end) as 报修,
sum(case when fLeiBie='2' then 1 else 0 end) as 咨询,
sum(case when fLeiBie='3' then 1 else 0 end) as 投诉
  FROM [DB_SZHPT_HQ].[dbo].[tb_FeedBack] group by year(fCreatTime)
GO


SELECT month(fCreatTime) as 月份 ,sum (case when fLeiBie='1' then 1 else 0 end) as 报修,
sum(case when fLeiBie='2' then 1 else 0 end) as 咨询,
sum(case when fLeiBie='3' then 1 else 0 end) as 投诉
  FROM [DB_SZHPT_HQ].[dbo].[tb_FeedBack] group by month(fCreatTime)
GO

 

posted @ 2016-12-09 18:28  哦~哦  阅读(219)  评论(0编辑  收藏  举报