Re: combine rows dependent on match two columns

From: NOVA <nova1427_at_gmail.com>
Date: Tue, 10 Mar 2009 07:56:13 -0700 (PDT)
Message-ID: <63259416-7767-49eb-a10c-4da91fea9809_at_r29g2000vbp.googlegroups.com>



On 10 ����, 16:50, Shakespeare <what..._at_xs4all.nl> wrote:
> NOVA schreef:
>
>
>
>
>
> > Dear all,
>
> > If I have table like this
>
> > A � � � � � � aa � � � � � � � B � � � � � � bb
> > 1 � � � � � � �5
> > 2 � � � � � � �7
> > � � � � � � � � � � � � � � � � � 1 � � � � � � �7
> > � � � � � � � � � � � � � � � � � 3 � � � � � � �6
>
> > I want to make the result like this
>
> > A or B � � � � � � aa � � � � � � � bb
> > 1 � � � � � � �5 � � � � � � � �7
> > 2 � � � � � � �7
> > 3 � � � � � � � � � � � � � � � �6
>
> > A or B is a column has all data avaliable in both A and B
>
> > help please
>
> I'm sure there are better ways, but how about
>
> select distinct nvl(t1.a,t2.b), t1.aa, t2.bb from example t1, example t2
> where t1.a=t2.b
> or ( t1.a is null and t2.b is not null and not exists (select 1 from
> example t3 where t3.a=t2.b))
> or ( t2.b is null and t1.a is not null and not exists (select 1 from
> example t4 where t1.a=t4.b))
>
> Shakespeare- ����� ���� ������� -
>
> - ��� ���� ������� -

I know this way

I want better ways

thanks Received on Tue Mar 10 2009 - 09:56:13 CDT

Original text of this message