Nth Highest Salary


  • 0
    H
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
      RETURN (
          # Write your MySQL query statement below.
          select a.salary from (select distinct salary from Employee) as a where (select count(*) from (select distinct salary from Employee) as b where b.salary > a.salary) = N-1 
      );
    END
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.