In my table I have the following columns:
id|name|gender
I would like to extract all the names which are duplicated, but I don\'t want to scan
SELECT name FROM Mytable GROUP BY name HAVING COUNT(*) > 1
To separate gender too, change the GROUP BY to name, gender
name, gender
To delete duplicate rows
DELETE MyTable WHERE ID NOT IN ( SELECT MIN(Id) FROM Mytable GROUP BY name )