Nth Highest Salary Accepted Answer


  • 0
    X

    '''CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    RETURN (
    # Write your MySQL query statement below.
    SELECT CASE
    WHEN COUNT(DISTINCT salary) >= N THEN
    (SELECT MIN(salary) FROM (SELECT DISTINCT salary FROM employee ORDER BY salary DESC LIMIT N) T1)
    ELSE NULL
    END
    FROM employee
    );
    END'''


Log in to reply
 

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