CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
declare M INT;
set M = N-1;
RETURN (
select e.Salary
from(select Salary from Employee
union select null as Salary) as e
order by Salary desc
limit M,1
);
END
网友评论