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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help : Order by with Union clause

Re: Help : Order by with Union clause

From: Marc Marchioli <marcm_at_pagemart.com>
Date: 1997/10/15
Message-ID: <34454C8B.3CE3@pagemart.com>#1/1

The answer if very simply. Noting that in a union you have no exact reference to a particular column since the unioned SQL's could in fact be entirely different tables/queries but the only requirement is that the TYPES of the columns be consistent with the SQL/UNION by position. Thus, the ANSI standard allows for ordering by position ONLY and not column name. This is optional in a simply query.

When is doubt check out the manual under UNIONS.

Marc Marchioli
The DataBase Group, Inc.
http://www.databasegroup.com

Suman Mehta 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
Received on Wed Oct 15 1997 - 00:00:00 CDT

Original text of this message

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