DEV Community

loading...

Answer: How can I remove duplicate rows?

boyukbas profile image baris ・1 min read

Assuming no nulls, you GROUP BY the unique columns, and SELECT the MIN (or MAX) RowId as the row to keep. Then, just delete everything that didn't have a row id:

DELETE FROM MyTable
LEFT OUTER JOIN (
SELECT MIN(RowId) as RowId, Col1, Col2, Col3
FROM MyTable
GROUP BY Col1,







Smart answer 1

Discussion (0)

pic
Editor guide