Re: How to identify a column in order by clause

From: DA Morgan <damorgan_at_x.washington.edu>
Date: Fri, 07 Jan 2005 22:59:05 -0800
Message-ID: <41df838b$1_1_at_127.0.0.1>


doichi wrote:

> Mr. Morgan,
> 10x for your long dump... without Oracle near at hand, I missmatched
> the case with table aliases (if table alias present, you must use it
> instead of table name to reference cols in ORDER BY clause, otherwise
> Oracle complains):
> SQL> SELECT ename, sal FROM emp WHERE ROWNUM < 2
> 2 ORDER BY emp.sal;
>
> ENAME SAL
> ---------- ---------
> SMITH 800
>
> SQL> 1
> 1* SELECT ename, sal FROM emp WHERE ROWNUM < 2
> SQL> c/emp/emp e
> 1* SELECT ename, sal FROM emp e WHERE ROWNUM < 2
> SQL> 2
> 2* ORDER BY emp.sal
> SQL> /
> ORDER BY emp.sal
> *
> ERROR at line 2:
> ORA-00904: invalid column name

Correct. Which is why I am amazed when people use table alias in single table SQL statements.

-- 
Daniel A. Morgan
University of Washington
damorgan_at_x.washington.edu
(replace 'x' with 'u' to respond)


----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
Received on Sat Jan 08 2005 - 07:59:05 CET

Original text of this message