PDA

View Full Version : Multiple Values delete duplicates



Pancakes1032
04-01-2015, 07:55 PM
I am having trouble adjusting this SQL coding. I'm trying to find and delete duplicates. It works when I'm looking for duplicates in status=status and caseid=caseid which is great. However I need status to only be removed as a duplicate if the caseid is a duplicate and the status is "Unprocessed" OR "Pending Verifs" OR "No Packet". I tried the code below but I don't think I'm writing the last part correctly. Again the code works when WHERE T2.caseid = T1.caseid AND T2.status = T1.status. Thanks for the help!



DELETE T1.*, T1.CFRRRID
FROM CFRRR AS T1
WHERE (((T1.CFRRRID)>(SELECT MIN(T2.CFRRRID)
FROM CFRRR T2
WHERE T2.caseid = T1.caseid AND T2.status = "Unprocessed" OR "Pending Verifs" OR "No Packet" AND = T1.status = "Unprocessed" OR "Pending Verifs" OR "No Packet"
)));