34,590
社区成员
发帖
与我相关
我的任务
分享
select * from [Client] where (select count(1) as num from Records where Records.cID = Client.cID) = 0 and (Select count(1) as nums from Hetong where Hetong.cId = Client.cId) = 0 and cYn = 1 and datediff(d,cLastUpdated,getdate()) > = 5 order by cDate desc
select * from [Client]
where ((not exists (select 1 from Records where Records.cID = Client.cID)
and not exists (Select 1 from Hetong where Hetong.cId = Client.cId))
or exists (Select 1 from Hetong where Hetong.cId = Client.cId and hState=XXXX))
and cYn = 1 and datediff(d,cLastUpdated,getdate()) > = 5 order by cDate desc
SELECT *
FROM [Client] c
WHERE NOT EXISTS (SELECT 1 FROM Records r WHERE r.cID = c.cID)
AND NOT EXISTS (SELECT 1 FROM Hetong h
WHERE h.cId = c.cId AND h.hState <> '没消费' --没消费的在这里排除掉,最终结果列出来
) AND cYn = 1
AND DATEADD(DAY, -5, GETDATE()) >= cLastUpdated
ORDER BY cDate DESC;
select * from [Client] c where
not exists (select 1 from Records r where r.cID = c.cID)
and not exists (Select 1 from Hetong h where h.cId = c.cId and h.hState=1)
and cYn = 1 and dateadd(day,-5,getdate())>=cLastUpdated
order by cDate desc
select * from [Client] where
(select count(1) as num from Records where Records.cID = Client.cID) = 0
and (Select count(1) as nums from Hetong where Hetong.cId = Client.cId and Hetong.hState=1) = 0
and cYn = 1 and datediff(d,cLastUpdated,getdate()) > = 5
order by cDate desc