Skip to content

Instantly share code, notes, and snippets.

@indatawetrust
Created May 18, 2020 08:33
Show Gist options
  • Save indatawetrust/8f908c73d8c25ac2509836630ff180c1 to your computer and use it in GitHub Desktop.
Save indatawetrust/8f908c73d8c25ac2509836630ff180c1 to your computer and use it in GitHub Desktop.
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE _N INT;
SET _N = N - 1;
RETURN (
# Write your MySQL query statement below.
select (
select distinct Salary from Employee order by Salary desc limit 1 offset _N
) as getNthSalary
);
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment