
Untitled
By: a guest on
May 8th, 2012 | syntax:
None | size: 1.31 KB | hits: 11 | expires: Never
SQL: Removing Duplicate records - Albeit different kind
TAB6
A B C
---------- ---------- -
1 2 A
2 1 A
2 3 C
3 4 D
A B C A B C
---------- ---------- - ---------- ---------- -
1 2 A or 2 1 A
2 3 C 2 3 C
3 4 D 3 4 D
select t1.*
from t6 t1
, t6 t2
where t1.a <> t2.b
and t1.b <> t2.a
and t1.rowid <> t2.rowid
/
A B C
---------- ---------- -
1 2 A
2 1 A
2 1 A
2 3 C
3 4 D
3 4 D
6 rows selected.
select *
from t6 t1
where exists (select * from t6 t2 where t1.a <> t2.b and t1.b <> t2.a)
/
A B C
---------- ---------- -
1 2 A
2 1 A
2 3 C
3 4 D
select distinct least(a, b) as a
, greatest(a, b) as b
, c
from t6
create index t6_fbi on t6(least(a, b)
, greatest(a, b)
, c )
/
select distinct
least(a, b) as a,
greatest(a, b) as b,
c
from
t6