解决:
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE result INT DEFAULT NULL;
SELECT Salary INTO result FROM (
SELECT Salary, DENSE_RANK() OVER (ORDER BY Salary DESC) as ranks
FROM Employee
) AS rankedSalaries
WHERE ranks = N
LIMIT 1;
RETURN result;
END;