NTH HIGHEST SALARY


  • 0
    W

    '''
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    DECLARE M INT;
    SELECT COUNT(DISTINCT SALARY) INTO M FROM EMPLOYEE;
    IF (M>=N) THEN
    RETURN (
    # Write your MySQL query statement below
    SELECT MIN(SALARY) FROM (SELECT DISTINCT SALARY FROM EMPLOYEE ORDER BY SALARY DESC LIMIT N) A

    );ELSE RETURN null;
    END IF;
    END;
    '''


Log in to reply
 

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