Find last 10 records by Customer
Posted on 2009-04-07
ID INT NOT NULL IDENTITY(1,1) PRIMARY_KEY
, Contacted TINYINT --(1 or 0)
, ContactDate SMALLDATETIME
Every time there is an attempt to contact a customer an entry is logged that shows the CustomerID, whether or not the customer was actually contacted (1 oir 0) and the date of the contact attempt.
Given that, I am trying to do the following:
Exclude (from a larger resutlset) anyone that has been unsuccessfully contacted 10 times in a row since 3/1/2009.
So, something like...
SELECT lots of Customer data FROM some different tables (that have CustomerID as a FK)
WHERE NOT EXISTS (or NOT IN) -- Code the Exclusion Here
This one is stumping me.
Thanks in advance!