Link to home
Start Free TrialLog in
Avatar of Sriv
Sriv

asked on

Delete Duplicates

Hi I have a table and  need to identify duplicates by creating an unique key  by concatenating col1+Col2+col3 and then keep last occurring duplicate for each group of duplicates.

How can we achieve this?
SOLUTION
Avatar of Jim Horn
Jim Horn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sriv
Sriv

ASKER

Mate your Answer keeps the first unique record and deletes the rest. however I need to keep the last unique record and delete the rest
Ok, what is the definition of first record and last in your table?
Avatar of Sriv

ASKER

Mate the above solution that you provided find duplicates and keeps first occurring (Ranked 1) duplicate and deletes other duplicates but my requirement is to keep the last ranked duplicate. We also have ID column which is identity column. We need to find  the duplicates and then based on each duplicate group we need to  keep the duplicate that has max ID column