Select Not In Other Tables
I am trying to come up with a way to determine which of my customers are not coming back in a 3 month time period. For instance I want to know which customers came to my store in January but did not come back in February, March or April.
My query looks like this:
Code:
SELECT
CustomerID, LastName, FirstName
FROM
vJan
WHERE
CustomerID NOT IN (Select CustomerId From vFeb) And
CustomerID NOT IN (Select CustomerId From vMar) And
CustomerID NOT IN (Select CustomerId From vApr)
ORDER BY LastName, FirstName
I thought that this is the correct way to write it but I am getting o rows returned and I know for a fact that not every customer who came in January has been back. What am I doing wrong?
Re: Select Not In Other Tables
Try this:
Code:
SELECT
CustomerID, LastName, FirstName
FROM
vJan
WHERE
vJan.CustomerID NOT IN (Select vFeb.CustomerId From vFeb) And
vJan.CustomerID NOT IN (Select vMar.CustomerId From vMar) And
vJan.CustomerID NOT IN (Select vApr.CustomerId From vApr)
ORDER BY LastName, FirstName