congr / world

2 stars 1 forks source link

LeetCode: 177. Nth Highest Salary #456

Closed congr closed 5 years ago

congr commented 5 years ago

https://leetcode.com/problems/nth-highest-salary/

image

congr commented 5 years ago
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
SET N=N-1;
  RETURN (
      # Write your MySQL query statement below.
      SELECT DISTINCT salary from Employee
      ORDER BY salary DESC LIMIT 1 OFFSET N
  );
END