Interview Questions   Tutorials   Discussions   Programs   

DB2 - How can we find nth max salary from A table?




339
views
asked mar August 25, 2014 12:00 PM  

How can we find nth max salary from A table?


           

1 Answers



 
answered By Mswami   0  
SELECT   *  FROM    TABLEA E1
WHERE   N =  (SELECT   COUNT(DISTINCT (E2.SAL))
          FROM     TABLEA E2

SELECT DISTINCT (a.sal) FROM EMP A WHERE &N = (SELECT COUNT (DISTINCT (b.sal)) FROM EMP B WHERE a.sal < = b.sal) WHERE   E2.SAL >= E1.SAL)

flag   
   add comment

Your answer

Join with account you already have

FF

Preview


Ready to start your tutorial with us? That's great! Send us an email and we will get back to you as soon as possible!

Alert