I have a database similar to this:
Name State
Bill CA
Joe NY
Susan CA
I know I can get a total count of the number of records for each state like this:
SELECT State, COUNT(*) as count FROM users GROUP BY State
I'm trying to delete all records where the total count of states is less than 2 (or any arbitrary number)
Something like this (Pseudocode):
DELETE FROM users WHERE totalUsersInState < 2
So the final database should be like this
Name State
Bill CA
Susan CA
What is the correct syntax for that? I can't figure it out.