How to keep only one row of a table, removing duplicate rows?

前端 未结 8 1611
小蘑菇
小蘑菇 2020-12-08 16:41

I have a table that has a lot of duplicates in the Name column. I\'d like to only keep one row for each.

The following lists the duplicates, but I don\'t know how to

8条回答
  •  Happy的楠姐
    2020-12-08 17:09

    WITH CTE AS
    (
        SELECT ROW_NUMBER() OVER (PARTITION BY [emp_id] ORDER BY [emp_id]) AS Row, * FROM employee_salary
    )
    
    
    DELETE FROM CTE
    WHERE ROW <> 1
    

提交回复
热议问题