0177.sql (216B)
1 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT 2 BEGIN 3 DECLARE M INT; 4 SET M = N - 1; 5 RETURN ( 6 SELECT DISTINCT salary 7 FROM Employee 8 ORDER BY salary DESC 9 LIMIT 1 10 OFFSET M 11 ); 12 END