mysql implementation of nth Highest


  • 0
    W
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
    BEGIN
    DECLARE i INT;
    SET i=N-1;
      RETURN (
        # Write your MySQL query statement below.
        Select
            IFNULL((Select Distinct Salary From Employee Order by Salary Desc Limit 1 Offset i), null)
        as getNthHighestSalary
    
    );
    END
    

Log in to reply
 

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