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: Combining outputs of queries!

Re: Combining outputs of queries!

From: Thomas Kellerer <BDHLDUUTPRWS_at_spammotel.com>
Date: Wed, 10 May 2006 16:17:13 +0200
Message-ID: <4ceav9F15k9fnU1@individual.net>

On 10.05.2006 16:11 Sameer wrote:
> I have outputs of several queries having two fields.
> These queries have one common field and an other field.
> The rows returned by all of them are same.
> For example:
>
> Query1: CommonField, Field1
> Query2: CommonField, Field2
> Query3: CommonField, Field3
> Query4: CommonField, Field4
> Query5: CommonField, Field5
>
> I want to combine output of these queries in one table having fields:
> CommonField, Field1, Field2, Field3, Field4, Field5
> One way is to create views for each of these queries as View1,
> View2,.... View5
> and then executing the statement:
>
> select View1.CommonField, View2.Field2, View3.Field3,... View5.Field5
> from View1,View2...View5.
>
> But this is a long way which requires temporary views.
>
> Is there any another efficient way to do this task in one command?

SELECT q1.commonField,

        q1.field1,
        q2.field2,
        q3.field3,
        q4.field4,
        q5.field5

FROM (query1) q1, (query2) q2, (query3) q3, (query4) q4, (query5) q5

Assuming query1 is
SELECT 'bla' commonfield, 42 field1 FROM dual;

this would be:

FROM (SELECT 'bla' commonfield, 42 field1 FROM dual) q1

and so on

Thomas

-- 
It's not a RootKit - it's a Sony
Received on Wed May 10 2006 - 09:17:13 CDT

Original text of this message

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