我想比较本月与去年这个月的统计数据 我正在使用sql数据库这是我的代码,它给了我月初至今
COUNT(CASE WHEN (MONTH(pm.DateAppIssued) = MONTH(GETDATE()) AND YEAR(pm.DateAppIssued) = YEAR(GETDATE())) then 1 end) AS [Issued]
这将为01/09/2016 - Getdate()
提供一些已发布的案例
我想要的是去年发布的案件数量01/09/2015 - 30/09/2015
感谢
答案 0 :(得分:1)
只需从YEAR(GETDATE())
COUNT(CASE WHEN (MONTH(pm.DateAppIssued) = MONTH(GETDATE()) AND
YEAR(pm.DateAppIssued) = YEAR(GETDATE())-1)
then 1 end) AS [Issued]