Nth Highest Salary (Parameter N)
Programming Interview
Hard
5 views
Problem Description
Table: Employees(emp_id, salary). Write a query pattern to get the Nth highest distinct salary (assume N is given).
Input Format
SQL tables are described in the question.
Output Format
Write the SQL query.
Official Solution
SELECT salary
FROM (
SELECT DISTINCT salary
FROM Employees
ORDER BY salary DESC
OFFSET :N-1 ROWS FETCH NEXT 1 ROWS ONLY
) t;
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!