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

Home -> Community -> Usenet -> c.d.o.tools -> Re: UNION Set Operator & Group/Order by

Re: UNION Set Operator & Group/Order by

From: Pierre Charpenay <pcharpenay_at_unilog.fr>
Date: 2000/06/21
Message-ID: <3950A0C1.49AE9C86@unilog.fr>#1/1

Yes and NO !

The ORDER BY clause can be use on global result of an UNION, but the GROUP BY clause can only be used on each queries of an UNION. So, you can write this :

select ... sum(a) ... from table_a ... group by ... UNION
select ... sum(b) ... from table_b ... group by ... order by ...

To apply the GROUP BY clause on the global result, you must write something like :

select ... sum(new_a) ...
from (select ... a new_a ... from table_a ...

      UNION
      select ... b new_a ... from table-b ...)
...
group by ...

Hope this helps

Bye

Richelle Hutchinson a écrit :
>
> Does anyone know if I can use an UNION Set Operator with a GROUP/ORDER BY?
>
> -Richelle Hutchinson
 

-- 
 Pierre CHARPENAY
Received on Wed Jun 21 2000 - 00:00:00 CDT

Original text of this message

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