Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SQL

SQL:RANK function to delete duplicate rows

DELETE E
    FROM [SampleDB].[dbo].[Employee] E
         INNER JOIN
    (
        SELECT *, 
               RANK() OVER(PARTITION BY firstname, 
                                        lastname, 
                                        country
               ORDER BY id) rank
        FROM [SampleDB].[dbo].[Employee]
    ) T ON E.ID = t.ID
    WHERE rank > 1;
 
PREVIOUS NEXT
Tagged: #function #delete #duplicate #rows
ADD COMMENT
Topic
Name
1+2 =