DELETE FROM table1 WHERE id IN (SELECT id FROM table1 GROUP BY id HAVING COUNT(id) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM table1 GROUP BY id HAVING COUNT(id) > 1)