Re: Help : Order by with Union clause

From: Thomas Kyte <tkyte_at_us.oracle.com>
Date: 1997/08/20
Message-ID: <33fa46b8.86264932_at_newshost>#1/1


On 19 Aug 1997 23:21:32 GMT, "Suman Mehta" <sumanp_at_yardi.com> wrote:

>Can we write an Order by Clause at the end of a select statement
>having the Union clause in it ?
>
>My SQL query (which has a union clause) works fine without
>it but gives an error message when I try to order by
>one of the columns.
>
>How do we overcome this problem ?
>
>
>----------------------------------------------
>Suman Mehta
>E-mail ID : sumanp_at_yardi.com

select a, b, c from T1
union all
select d, e, f from T2
order by 3, 2, 1

will order by c, b, a (f, e, d)

Use the numeric position of the column in the order by.

Thomas Kyte
tkyte_at_us.oracle.com
Oracle Government
Bethesda MD

http://govt.us.oracle.com/ -- downloadable utilities



Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Wed Aug 20 1997 - 00:00:00 CEST

Original text of this message