Leetcode Problem 177. Nth Highest Salary

177. Nth Highest Salary

Leetcode Solutions

Finding the Nth Highest Salary Using SQL and Pandas

  1. Use SELECT DISTINCT salary to get unique salaries.
  2. Sort the results in descending order using ORDER BY salary DESC.
  3. Use LIMIT M, 1 to skip the first M rows and return the next row, where M is N-1.
  4. If there is no such nth highest salary, the query will return null.
erDiagram
    Employee {
        int id PK
        int salary
    }

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...