$ 0 0 This can also work: DELETE FROM YourTable WHERE IdocNo in (SELECT distinct IdocNo FROM Yourtable where Status = "SUCCESS") AND Status = "ERROR"