Multiple choice technology programming languages

Which of the following queries can be used to delete duplicate records from a table -

  1. delete from table_name where rowid not in (select max(rowid) from table group by duplicate_values_field_name);

  2. delete from table_name where rowid in (select max(rowid) from table group by duplicate_values_field_name);

  3. c)delete from table_name where rowid not in (select max(rowid) from table);

  4. delete from table_name where rowid not in (select rowid from table group by duplicate_values_field_name);

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

To delete duplicates, you keep one instance (usually the one with max rowid) and delete the rest. Option A correctly identifies rows where rowid is NOT IN the maximum rowid for each duplicate group. Options B and C would keep the wrong records or delete all records. Option D is incorrect because selecting rowid directly without an aggregate in the GROUP BY clause won't identify the max per group.