Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: UNION Set Operator & Group/Order by
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 ...)...
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 CHARPENAYReceived on Wed Jun 21 2000 - 00:00:00 CDT