CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT

BEGIN

declare m int;

declare a int;

set a = N - 1;

if N = 0 then set m = NULL;

elseif N >= 1 then select Salary into m from Employee group by Salary order by Salary desc limit a, 1;

end if;

RETURN m;

END