LeetCode-177. 第N高的薪水(中等)

LeetCode-177. 第N高的薪水(中等)_第1张图片
题目来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/nth-highest-salary
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。

本人思路:
1、第n高薪水问题可以想到去重后排序,再用limit分页,注意limit分页语法
(此题有多种思路)

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN 
  set N :=N-1;
  RETURN (
      # Write your MySQL query statement below.
      select distinct salary
      from Employee 
    --   group by salary
      order by salary desc
      limit N,1     
  );
END

你可能感兴趣的:(数据库刷题)