LeetCode 177: Nth Highest Salary

Database

Problem Description

Explanation

To find the nth highest distinct salary from the Employee table, we can use a SQL query that selects the distinct salary values in descending order and skips the first n-1 results to get the nth highest salary.

Solutions

# Write your Java solution here
SELECT DISTINCT salary AS getNthHighestSalary
FROM Employee
ORDER BY salary DESC
LIMIT n-1, 1

Loading editor...