My simple solution with order by and limit
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\n    BEGIN\n      RETURN (\n          # Write your MySQL query statement below.\n          select if(coun
    CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT\n    BEGIN\n      RETURN (\n          # Write your MySQL query statement below.\n          select if(count(*)<N,null,min(s.Salary))\n          from \n          (select distinct Salary\n          from Employee\n          order by Salary DESC\n          limit 0,N) s\n      );\n    END
[]