Skip to content

Latest commit

 

History

History
18 lines (15 loc) · 302 Bytes

Nth Highest Salary.md

File metadata and controls

18 lines (15 loc) · 302 Bytes

MySQL Solution

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

Links