ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  SQL Data Types
Subject:   how do we find nth highest in SQL
Date:   2006-04-17 07:57:07
From:   sainiks
Response to: how do we find nth highest in SQL

1.
Select * from Employee where salary =
(Select max(Salary) from Employee where salary < (Select max(Salary) from Employee where
Salary<(Select max(Salary) from Employee where
Salary < N


The above query can be continued n timesif you require nth highest salary
2.
Select * From Employee E1 Where
(N-1) = (Select Count(Distinct(E2.Salary)) From Employee E2 Where
E2.Salary > E1.Salary)


here you require N th highest salary


Those were two choices , i think 2nd one will take a bit time.


1 to 1 of 1
  1. how do we find nth highest in SQL
    2006-06-27 05:16:28  jewel_plat [View]

    • how do we find nth highest in SQL
      2006-09-05 03:32:25  kunalpawar [View]

1 to 1 of 1