Home » SQL & PL/SQL » SQL & PL/SQL » Alias in ORDER BY (Oracle9i)
Alias in ORDER BY [message #399555] Thu, 23 April 2009 00:13 Go to next message
ramesh55.sse
Messages: 262
Registered: December 2008
Location: Hyderabad
Senior Member
SQL> SELECT empno,ename,sal "newsal"
FROM emp1
ORDER BY newsal;
SQL> /
ORDER BY newsal
*
ERROR at line 3:
ORA-00904: "NEWSAL": invalid identifier

SQL> SELECT empno,ename,sal "NEWSAL"
FROM emp1
ORDER BY newsal;

Why it's not raising error.


Re: Alias in ORDER BY [message #399559 is a reply to message #399555] Thu, 23 April 2009 00:38 Go to previous messageGo to next message
Frank
Messages: 7901
Registered: March 2000
Senior Member
My guess is that you know pretty well what's going on here.
Why else would you use the double quotes in the alias?

Time to start thinking & reading some docs before posting each question you can think of.
Re: Alias in ORDER BY [message #399561 is a reply to message #399559] Thu, 23 April 2009 00:40 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
Frank wrote on Wed, 22 April 2009 22:38
My guess is that you know pretty well what's going on here.
Why else would you use the double quotes in the alias?

Time to start thinking & reading some docs before posting each question you can think of.



This assume intelligence not yet in evidence.
Re: Alias in ORDER BY [message #399566 is a reply to message #399555] Thu, 23 April 2009 00:48 Go to previous messageGo to next message
Michel Cadot
Messages: 68704
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
A useful link for you: SQL Reference.

Please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: Alias in ORDER BY [message #400078 is a reply to message #399555] Sat, 25 April 2009 15:34 Go to previous message
Barbara Boehmer
Messages: 9099
Registered: November 2002
Location: California, USA
Senior Member
Consider that the following also does not raise an error.

select empno, ename, sal "newsal" from emp order by "newsal";

It has to do with case sensitivity caused by quoting. Otherwise, everything defaults to upper case.
Previous Topic: CASE and DECODE
Next Topic: Homeowrk Help: Joining Multiple Tables
Goto Forum:
  


Current Time: Sun Nov 03 00:39:38 CDT 2024