-
SELECT Empno, Ename, Job, Mgr, Hiredate, Sal
FROM
(SELECT Empno, Ename, Job, Mgr, Hiredate, Sal
FROM Emp
ORDER BY NVL(Sal, 0) DESC)
WHERE ROWNUM < 6;
what will happen if I select only emp no in the select statement will it effect my resultset if yes then what is the reason. If I mad changes then my query will be like this.
SELECT Empno
FROM
(SELECT Empno
FROM Emp
ORDER BY sal DESC,empno)
WHERE ROWNUM < 6;
It is urgent plz. reply me as soon as possible
Thanks in Advance
-
Changes in selectlist don't have impact on ordering.
But you changed ORDER BY clause and you probably get different results.
In your first query the order of the rows with identical salary is not guaranteed.
A unique column in ORDER BY as seen in the second query corrects that.