Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Combining outputs of queries!
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
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 SonyReceived on Wed May 10 2006 - 09:17:13 CDT