Link to home
Start Free TrialLog in
Avatar of Tpaul_10
Tpaul_10Flag for United States of America

asked on

Deleting duplicate records in SQL

Experts,

Attached is the documents outlines the sample data and I want to delete the rows that are highlighted in red color. Have been trying with multiple scripts and not successful.

Thanks in advance
Document.docx
SOLUTION
Avatar of rlarian
rlarian
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
Avatar of Tpaul_10

ASKER

Didn't get it quite right with the above code rlarian, how about the following query and gets me what I wanted. Can you please review?

Delete ItemDetails where itemId not in (
select min(itemID) from ItemDetails A
group by ItemNumber,ItemCode) 

Open in new window


Thanks
just tested. that'll work.
ASKER CERTIFIED 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