| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: How to identify a column in order by clause
I would go for the alias if had to choose between alias and tbl.col
notation, but there is better alternative:
Almost sure that Oracle will not accept tbl.col notation in ORDER
clause if alias is present (Sorry just uninstalled Oracle and can not
test it).
MS SQL is more generous and allows any permutation (tbl.aslias,
tbl.col, alias...).
MS Jet DB engine howerver does not allow aliases in ORDER BY clause.
MySQL and Postgre have no problems with aliases in ORDER BY clause.
All of the reviewed db engines work fine with 1, 2, n (positional
notation) in the ORDER BY clause. So if you want "write once run
anywhere" I would go with positional ORDER BY notation like this:
SELECT [emp.]empno [AS alias], [emp.]ename [AS alias], [emp.]sal [AS
alias]
FROM emp [AS alias]
ORDER BY 1, 2
BR,
Doich
todd_run wrote:
> The question I have is: In a select statement that uses column
> aliases, should the order by clause include the column name or the
> column alias?
>
Received on Fri Jan 07 2005 - 03:03:34 CST
![]() |
![]() |