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: ORDER BY column names vs column numbers

Re: ORDER BY column names vs column numbers

From: Chris Hamilton <ToneCzar_at_erols.com>
Date: Fri, 09 Apr 1999 11:39:42 GMT
Message-ID: <370de6c5.563890@news.erols.com>


On 9 Apr 1999 09:15:41 GMT, anneke_at_echelon.nl (Anneke Treep) wrote:

>Hi All,
>
>I have run into this problem using SQL*Plus: Release 3.3.3.0.0 on an
>SCO_SV release 3.2v5.0.4 system running Oracle 7.3.3.3.0.
>
>I am selecting some appointments as follows:
> SELECT appt.emp1 employee, appt.team1 team, appttime, custno,
>custname
> FROM various-tables
> WHERE various-criteria
> UNION
> SELECT appt.emp2 employee, appt.team2 team, appttime, custno,
>custname
> FROM various-tables
> WHERE various-criteria
> ORDER BY 1,2,3,4
>
>This works fine.
>But, when instead I use the following:
> ORDER BY employee, team, appttime, custno
>the ordering on the appttime (and custno?) fields disappears???
>
>I prefer to use column names instead of numbers, but why cant I?

ORDER BY in a UNION or MINUS only works with column numbers. This is because the columns may not necessarily have the same name in the different parts of the query.

Chris



Christopher Hamilton
Oracle DBA -- Wall Street Sports
chris_at_wallstreetsports.com
http://www.wallstreetsports.com/ Received on Fri Apr 09 1999 - 06:39:42 CDT

Original text of this message

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