Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help with remove reversed duplicate rows?

80484Aug 20 2009 — edited Aug 21 2009
Hi:

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?
This post has been answered by Peter Gjelstrup on Aug 20 2009
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 18 2009
Added on Aug 20 2009
14 comments
851 views