Wim, your inner query "TBL" is referring the inner table, not the outer one, so TBL2.cust_id = TBL.cust_id is trivially satisfied.
So you need
Code:
SELECT DISTINCT CUST_ID
FROM TBL AS TBL1
WHERE PAY_DT >= '2006-01-01'
AND NOT EXISTS (SELECT 1
FROM TBL
WHERE CUST_ID = TBL1.CUST_ID
AND PAY_DT < '2006-01-01')
The following is an alternative solution: it gives only the customers for which the first payment date is after a given date:
Code:
SELECT cust_id
FROM tbl
GROUP BY cust_id
HAVING min(pay_dt) >= '2006-01-01'
Not necessarily more performant than the first solution, unless there is an index on the column pair (cust_id,pay_dt).
Otherwise it depends on the number of different customers and the number of entries per customer.
E.g., if there are relatively few payments after the reference date (say 1% of the table) the first solution will run faster.