Forum Moderators: open
I want to do a set difference to select the people who enquire but diddnt buy - something like
(SELECT Name FROM Enquiries)
EXCEPT
(SELECT Name FROM Sales)
This gives error - Incorrect syntax
Any ideas?
Thanks.
ASPDaddy
This should do what you want:
SELECT Name
FROM Enquiries WITH (NOLOCK)
WHERE Name NOT IN (SELECT Name FROM Sales WITH (NOLOCK))
SELECT Name
FROM Enquiries WITH (NOLOCK)
where not exists (select 1 from sales with (nolock) where sales.name =enquiries.name)