Problem
Write a SQL query to get the nth highest salary from the Employee table.
1 |
|
For example, given the above Employee table, the nth highest salary where n = 2 is 200. If there is no nth highest salary, then the query should return null.
1 |
|
Explanation
- We can get the
MAX
salary of Employee E1WHERE
E2.Salary is greater than E1.Salary andCOUNT(DISTINCT(E2.Salary))
isN-1
.
Solution
1 |
|