Reputation: 33
What is the best way to write this query:
SELECT ID FROM table WHERE "no row with the ID has a created date > '1/1/2012'" GROUP BY ID
In summary, I only want to see grouped ID's where every row has a created date > '1/1/2012'
Upvotes: 0
Views: 351
Reputation: 1269445
Use a having
clause and look at the maximum created date:
SELECT ID
FROM table
GROUP BY ID
HAVING MAX(CreatedDate) <= '2012-01-01'
Upvotes: 2