1 CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
2 BEGIN
3   SET N := N - 1;
4   RETURN (
5       # Write your MySQL query statement below.      
6       select (select distinct Salary from Employee order by Salary desc limit N,1)
7   );
8 END

使用子查询、distinct和limit来完成查询。

posted on 2020-07-23 16:13  Sempron2800+  阅读(105)  评论(0编辑  收藏  举报