Help with remove reversed duplicate rows?
80484Aug 20 2009 — edited Aug 21 2009Hi:
I have an application where I need to remove reversed duplicate rows, such as this:
select 'A' x, 'B' y from dual
union all
select 'C', 'D' from dual
union all
select 'B','A' from dual;
Output is:
X Y
- -
A B
C D
B A
What I need is to remove the 'B A' row because it already exists in reverse form as 'A B'. It does not matter which row is kept, 'A B' or 'B A'. Just one of them needs to be removed and the other needs to stay.
Note that the actual query to generate the data is a little more involved, but I can use a with clause to make it an inline view. I'm hoping that the actual mechanics are not relevant. If that is not the case, please let me know and I'll post more details about the actual query.
Any ideas?