Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2004
    Location
    India
    Posts
    15

    Question Unanswered: ROWNUM and ORDER BY

    Am using Oracle 9i.

    Just wanted to know in which order the db will execute my query if my query contains a 'WHERE ROWNUM < 1000' and an 'ORDER BY ...'.
    The documentation says that the order of evauation depends upon the indexes used in the ORDER BY, but doesn't specify clearly in which order.

    Please help.

  2. #2
    Join Date
    May 2003
    Location
    France
    Posts
    112

    Re: ROWNUM and ORDER BY

    You can't use ROWNUM and ORDER BY in the same select because the pseudo column ROWNUM is affected before the sort.

    So, you have to do :

    Select ... FROM (SELECT ... FROM .... ORDER bY...) WHERE ROWNUM<1000

Posting Permissions

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