Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: How to write SQL statement.

Re: How to write SQL statement.

From: Fernando Carvalho <f.carvalho_at_mail.telepac.pt>
Date: Mon, 14 Sep 1998 23:02:17 +0200
Message-ID: <6tk750$j4f$1@duke.telepac.pt>


Another solution is:

select col1, sum(decode(Tab, 'T1', Tot, 0)), sum(decode(Tab, 'T2', Tot, 0)) from
(select col1, 'T1' Tab, sum(col3) Tot from Table_A group by col1 union
select col1, 'T2' Tab , sum(col3) Tot from Table_B group by col1) group by col1

Regards

Fernando Carvalho

Aung Aung > wrote in message
<01bddfc8$4f664e80$7cdededd_at_aung.acmarcom.com.sg>...
>Hello,
>
>I have one problem to retrieve data in one statement. It is as follows:
>Table A. col1 col2 col3
> A X 100
> A Y 200
> B X 100
>
>Table B. A X 10
> A X 20
> A Y 10
> A Y 20
> B X 50
>
>I would like to have the result as
> A 300 60 (A,300 from Table A, 60 from Table B)
> B 100 50 (B,100 from Table A, 50 from Table B)
>
>Thank you,
>
>Aung.
>
Received on Mon Sep 14 1998 - 16:02:17 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US