日期:2014-05-17 浏览次数:20555 次
SELECT Y.业务员姓名
FROM Ytable Y
WHERE NOT EXISTS ( SELECT 1
FROM Mtable M
INNER JOIN Ctable C ON M.汇款客户ID = C.cid
WHERE C.业务员ID = Y.业绩员ID --少些一个Y
AND M.date <= DATEADD(m, -3, GETDATE()) )
select *
from Ytable a
where not exists
(select 1
from Ctable b
inner join Mtable c on b.客户ID=c.回款客户ID
where datediff(mm,c.回款时间,getdate())<=3)
select *
from Ytable
left join Ctable on Ctable.YID=Ytable.YID
left join Mtable on Mtable.CID=Ctable.CID
where Mtable.Date<=dateadd(m,-3,getdate()) and Mtable.CID is null