LeetCode 177. Nth Highest Salary

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

0 Comments:

Post a Comment