Skip to content

Commit 9e660c3

Browse files
authored
Create 177_nth_highest_salary.sql
1 parent 32d97e8 commit 9e660c3

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
2+
BEGIN
3+
SET N=N-1;
4+
RETURN (
5+
# Write your MySQL query statement below.
6+
Select distinct(salary) from Employee
7+
Order by salary desc
8+
LIMIT 1 OFFSET N #Offset skips n rows and we can't do any calculation like n-1 here, so we had to set that out before
9+
);
10+
END

0 commit comments

Comments
 (0)