Re: How to identify a column in order by clause

From: -CELKO- <jcelko212_at_earthlink.net>
Date: 31 Dec 2004 21:38:51 -0800
Message-ID: <1104557931.005232.8560_at_c13g2000cwb.googlegroups.com>


>> 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? <<

Column aliases. In Standard SQL, the ORDER BY clause is part of a CURSOR. The CURSOR sees the result set of the SELECT statement, converts it into a non-relational sequential file structure and sorts it if there is an ORDER BY clause. It does not know about the base table column names, only the alias name in the result set that is passed to it.

SQL Server is still based on a file system model from its Sybase "code museum" heritage, so you can attach ORDER BY in places that should be illegal. Received on Sat Jan 01 2005 - 06:38:51 CET

Original text of this message