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
MAXsalary of Employee E1WHEREE2.Salary is greater than E1.Salary andCOUNT(DISTINCT(E2.Salary))isN-1.
Solution
1 | |