Leetcode: Nth Highest Salary, MySQL

Status: Accepted
14 / 14 test cases passed.
Runtime: 484 ms, faster than 48.85% of MySQL online submissions
Memory Usage: 0B, less than 100.00% of MySQL online submissions

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
  SET N = N - 1;
  RETURN (
      SELECT DISTINCT Salary
      FROM Employee
      ORDER BY Salary DESC
      LIMIT 1 OFFSET N
  );
END

More from Joshua
All posts