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

Thread: Query

  1. #1
    Join Date
    Dec 2001
    Posts
    22
    Hi,

    The query will return me 10 rows. I want to display only 3 rows. I dont want to use rownum or rank(). What is the alternative solution.

    SELECT * FROM (SELECT EMPNO,ENAME FROM EMP ORDER BY EMPNO DESC)

    Regards,

    Sampath

  2. #2
    Join Date
    Feb 2001
    Posts
    180
    In that case use a cursor and loop 3 times.
    Or delete 7 rows.
    Regards
    Ben de Boer

  3. #3
    Join Date
    Jun 2002
    Posts
    22
    Use of analitic functions is the alternative solution.

    SELECT * FROM (SELECT EMPNO,ENAME , row_number() over( ORDER BY EMPNO DESC) rn FROM scott.EMP )
    where rn < 4
    Aleš

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