Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: ORDER BY column names vs column numbers
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