This query keeps exactly one row for each set of duplicates (the one with the maximum ROWID) and deletes the rest. Grouping by the duplicate fields identifies duplicate groups, and selecting NOT IN MAX(ROWID) safely deletes all redundant records except the single unique representative record.