Saturday, January 2, 2010

ORACLE-Delete Same Multiple Rows Except One

To delete all the rows which have the same data except one.

(In this example we suppose that your table has same data in ID1 and ID2 columns.)

delete from t1 A

where rowid != ( select min(rowid) from t1 B

where B.ID1 = A.ID1

and B.ID2 = A.ID2)

No comments:

Post a Comment