Custmer Qurry? How Do I ?

K

Koorosh

Hi

I am trying to get the IDs of all those customers who have not purchased
anything in the last 3 months. What SQL query do I use? The table has 2
columns: CustomerID and PurchaseDate.


Many thanks
 
O

Ofer Cohen

I assume you have Customer table, using a sub query you can achieve that

Select * From CustomersTable Where
CustomerID Not In (Select CustomerID From PurchaseTable
Where PurchaseDate > DateAdd("m",-3,Date()))
 
J

John W. Vinson

Hi

I am trying to get the IDs of all those customers who have not purchased
anything in the last 3 months. What SQL query do I use? The table has 2
columns: CustomerID and PurchaseDate.

I presume you also have a Customer table? If so, that will be needed:

SELECT Customers.CustomerID, <other fields as needed>
FROM Customers
WHERE NOT EXISTS
(SELECT CustomerID FROM yourothertable
WHERE PurchaseDate > DateAdd("m", -3, Date()));

John W. Vinson [MVP]
 
Top