如何判断前3天这个SMS_HistoryRecord表有没有记录
--做判断先查询统计表是否有记录-前1、2、3天的数据
select @SubAMount_1=COUNT(case when CONVERT(varchar(8),SubmitDate,112)= CONVERT(varchar(8),DATEADD(day,-1,getdate()),112) then 1 else null end)
@SubAMount_2=COUNT(case when CONVERT(varchar(8),SubmitDate,112)= CONVERT(varchar(8),DATEADD(day,-2,getdate()),112) then 1 else null end)
@SubAMount_3=COUNT(case when CONVERT(varchar(8),SubmitDate,112)= CONVERT(varchar(8),DATEADD(day,-3,getdate()),112) then 1 else null end)
from SMS_SubmitRecord