NTH HIGHEST SALARy


  • 0
    L

    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    RETURN (
    # Write your MySQL query statement below.
    select min(Salary) from Employee where Salary in (
    select t.Salary from (
    select DISTINCT Salary from Employee order by Salary Desc limit N
    ) as t where N <= (
    select count(DISTINCT Salary) from Employee
    )
    )

    );
    END


Log in to reply
 

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