Search This Blog

Thursday, June 28, 2007

Delete Duplicate Rows


SQL> select * from taj;

CO CO CO
-- -- --
a a a
a a b
a b c
b b b
b b c
c c c
c c d
c d e
b c d
b c d

10 rows selected.

SQL> ed
Wrote file afiedt.buf

1 delete from taj t1
2 where t1.rowid >
3 ( select min(t2.rowid) from taj t2
4* where t1.col1 = t2.col1 and t1.col2 = t2.col2 and t1.col3
= t2.col3)
SQL> /

1 row deleted.

SQL> select * from taj;

CO CO CO
-- -- --
a a a
a a b
a b c
b b b
b b c
c c c
c c d
c d e
b c d

9 rows selected.

No comments: