177. Nth Highest Salary
Use limit, offset, order by
together
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 | +------------------------+ |
Soulution:
1 | CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT |
1 | -- alter |