⌘K
Flycodx

Nth Highest Salary Function

Nth Highest Salary Function

MediumSQL0% accepted

Write a SQL function getNthHighestSalary(N INT) that returns the Nth highest salary from the Employee table. The function should handle N > total distinct salaries.

Approach

Write SQL function for Nth highest salary using window functions.

Input

Employee: [(1,100),(2,200),(3,300)], N=2

Output

200

Scenarios & Expected Answers

Sign in to continue

Create a free account to view answers and mark progress.

  • Free forever — no credit card
  • Theory Q&A with detailed answers
  • Points, streaks & leaderboards
Auto Save On