日期:2014-05-18 浏览次数:20488 次
select distinct b.[Name],b.Phone from TaskInfo a left join UserInfo b on (a.Members=b.[Name] or a.Principal=b.[Name]) where a.Status in ('0','1','2','3') and case a.Status when '3' then 'datediff(day,a.YQTime,getdate())=0' else 'datediff(a.EndDate,getdate())=0' end
select distinct b.[Name],b.Phone from TaskInfo a left join UserInfo b on (a.Members=b.[Name] or a.Principal=b.[Name]) where a.Status in ('0','1','2','3') and case a.Status when '3' then datediff(day,a.YQTime,getdate()) else datediff(DAY,a.EndDate,getdate()) end = 0
------解决方案--------------------
--select distinct b.[Name],b.Phone from TaskInfo a left join UserInfo b on (a.Members=b.[Name] or a.Principal=b.[Name]) --where a.Status in ('0','1','2','3') and --case a.Status --when '3' then 'datediff(day,a.YQTime,getdate())=0' --else 'datediff(a.EndDate,getdate())=0' --end select distinct b.[Name],b.Phone from TaskInfo a left join UserInfo b on (a.Members=b.[Name] or a.Principal=b.[Name]) where a.Status=3 and datediff(day,a.YQTime,getdate())=0 or a.Status in(0,1,2) and datediff(day,a.EndDate,getdate())=0