I am looking for an SQL query to select all records not selected by another query on the same table. Specifically I want to select all records which have duplicates of a particular field('fieldA') and then delete all but one of those records.
So a select statement might be something like the following (which doesn't work!):
select * from table where id not in(select * from table group by fieldA)
If a single query is not possible then what would be the most efficient solution?