← Back to SQL Challenges
SQLIntermediate
Find the Nth Highest Salary
Tests your understanding of subqueries, OFFSET, and window functions like DENSE_RANK().
Problem Statement
Write a SQL query to report the nth highest salary from the Employee table. If there is no nth highest salary, the query should report null.
Real World Scenario:
In HR analytics, you often need to find the top earners or the median earners across different departments for compensation analysis.
Input / Output
Input: Table Employee with columns: `Id` (int), `Salary` (int)
Output: A single column `getNthHighestSalary(N)`.
Constraints
- The value of N is provided as a parameter to the function or query.
- You must handle the case where N is greater than the number of unique salaries.
Interactive Playground
Loading...
Console Output
Click "Run Code" to see the output here.