Search This Blog

Thursday, June 28, 2007

Duplicate Rows Selections


SQL> create table taj ( col1 char(2),col2 char(2), col3 char(2));

Table created.


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

8 rows selected.

SQL> select * from taj t1
2 where t1.rowid >
3 ( select min(t2.rowid) from taj t2
4 where t1.col1 = t2.col2);

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

6 rows selected.


Note: According your need and conditions add column name in subquery where clause

No comments: