DBAsupport.com Forums - Powered by vBulletin
Page 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: TOP FIVE

  1. #11
    Join Date
    Jul 2000
    Posts
    296
    EMPNO SALARY
    1 100
    2 200
    3 300
    4 400
    5 500
    6 500
    7 700

    With rownum you get 500 once, and you don't know which empno.

  2. #12
    Join Date
    Apr 2001
    Location
    Czechia
    Posts
    712
    OK, but the original question doesn't mention empno at all ...

  3. #13
    Join Date
    May 2001
    Posts
    11

    Cool

    Hi
    This will also work

    select distinct a.sal from emp a
    where 5>=(select count(distinct sal) from emp b where b.sal >=a.sal)
    order by a.sal desc

    just in place of 5 put what u want the top n salaries

    cheers
    sarath d

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