DEV Community

Discussion on: Deleting duplicate value at the same column in table of sql

Collapse
 
rodkammer profile image
Rodrigo Kammer

Here's another approach:

WITH Dups AS(
   SELECt [name],
          ROW_NUMBER() OVER(PARTITION BY [name]
                                ORDER BY [Id]) AS RN
      FROM dbo.fruits
)
DELETE FROM Dups WHERE RN > 1
Enter fullscreen mode Exit fullscreen mode