NVL with ORDER BY [message #283352] |
Mon, 26 November 2007 22:06 |
ORAGENASHOK
Messages: 240 Registered: June 2006 Location: Chennai
|
Senior Member |
|
|
Hi all,
when i am using nvl with order by clause it will show an error as SELECTED FAILURE.
Ex:
select nvl(emp_no,' ') from emp where emp_id like '123%' order by emp_id;
The above is the sample query.I am also planned to use the join in the above query.
|
|
|
|
Re: NVL with ORDER BY [message #283554 is a reply to message #283388] |
Tue, 27 November 2007 08:08 |
ORAGENASHOK
Messages: 240 Registered: June 2006 Location: Chennai
|
Senior Member |
|
|
Thank You Its working fine with replacement of space into '1'
Even when i am trying to combine the one or more another tables into the query and with the ORDER BY clause it will not work.
For Example :
select nv(a.emp_no,' '),nvla.ename,' '),nvl(b.dept,' ')
from emp a,dept b
where a.emp_no=b.emp_no
order by a.emp_no
It shows the Error : ORA-01791 not a SELECTed expression
|
|
|
|
|
|
|
|
|
|
Re: NVL with ORDER BY [message #288832 is a reply to message #283554] |
Tue, 18 December 2007 21:39 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
Have you solved your problem?
"The alias [of a column] can be used in the ORDER BY clause"
"To order by a lengthy select list expression, you can specify its position, rather than duplicate the entire expression, in the ORDER BY clause"
SELECT ename, deptno, sal
FROM emp
ORDER BY 2 ASC, 3 DESC
David
|
|
|