Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136

    Unanswered: To select a limited number of records

    Hello All!

    May be it sounds very trivial, but how can i select a limited number of records in Oracle, like in Microsoft SQL Server

    select top 1 ... ?

    Thanks in advance for your help!
    Regards,
    Julia

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Use ROWNUM, e.g.:

    select ename, sal from
    ( select ename, sal from emp order by sal desc)
    where rownum = 1;

    Note that the following would not work:

    select ename, sal from emp
    where rownum = 1
    order by sal desc;

    ... because the ROWNUM is applied before the ORDER BY. You will get 1 record, but it will not necessarily have the top salary value.

  3. #3
    Join Date
    Feb 2004
    Location
    Germany
    Posts
    136
    Thank you, Tony!
    Regards,
    Julia

Posting Permissions

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