View Code
select sum(c) from ( select count(*) as c from auditingapply where AuditingStatus in (4400000 ) and MakeDraftMan=9500 union select count(*) as c from auditingapply where AuditingStatus in (4400004 ) and MakeDraftMan=9500 and createtime>( select case when month(getdate())-5<0 --如果当前月份小于五月,则年份为当前年份-1,月份为:12+5-当前月份 then convert(datetime,(convert(varchar(4),year(getdate())-1 )+'-'+convert(varchar(4),12+month(getdate())-5 )+'-1')) else --月份大于5,则年份就是当前年份,月份为当前月份-5 convert(datetime,(convert(varchar(4),year(getdate()))+'-'+convert(varchar(4),month(getdate())-5 )+'-1')) end ) ) as temp