DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2

Thread: Regarding order by probelm

  1. #1
    Join Date
    Sep 2000
    Posts
    305
    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

  2. #2
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width