top-n queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sheikshabuddin
    New Member
    • Nov 2008
    • 1

    top-n queries

    how to retrieve the top-nth employee in the employees table regarding salary
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    try to use rownum after sorting as per salary.

    you need to post the query that you have tried for fouther assistance from our experts.

    Comment

    • st33chen
      New Member
      • Jan 2009
      • 5

      #3
      for example
      Code:
       
      SELECT * 
      FROM (
      SELECT DEPTNO, ENAME, SAL, ROW_NUMBER() OVER(PARTITION BY DEPTNO ORDER BY SAL DESC) TOPN
      FROM SALES
      )
      WHERE TOPN<=1
      Last edited by amitpatel66; Jan 19 '09, 01:38 PM. Reason: code tags

      Comment

      Working...