Skip to content

Commit

Permalink
solve problem Nth Highest Salary
Browse files Browse the repository at this point in the history
  • Loading branch information
P-ppc committed Nov 24, 2018
1 parent e2e6369 commit 2058084
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,5 @@ All solutions will be accepted!
|176|[Second Highest Salary](https://leetcode-cn.com/problems/second-highest-salary/description/)|[mysql](./database/SecondHighestSalary)|Easy|
|626|[Exchange Seats](https://leetcode-cn.com/problems/exchange-seats/description/)|[mysql](./database/ExchangeSeats)|Medium|
|178|[Rank Scores](https://leetcode-cn.com/problems/rank-scores/description/)|[mysql](./database/RankScore)|Medium|
|180|[Consecutive Numbers](https://leetcode-cn.com/problems/consecutive-numbers/description/)|[mysql](./database/ConsecutiveNumbers)|Medium|
|180|[Consecutive Numbers](https://leetcode-cn.com/problems/consecutive-numbers/description/)|[mysql](./database/ConsecutiveNumbers)|Medium|
|177|[Nth Highest Salary](https://leetcode-cn.com/problems/nth-highest-salary/description/)|[mysql](./database/NthHighestSalary)|Medium|
2 changes: 2 additions & 0 deletions database/NthHighestSalary/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Nth Highest Salary
We can solve this problem by MYSQL FUNCTION
9 changes: 9 additions & 0 deletions database/NthHighestSalary/solution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
DECLARE M INT;
SET M = N - 1;
RETURN (
# Write your MySQL query statement below.
select distinct Salary from Employee order by Salary desc limit M, 1
);
END

0 comments on commit 2058084

Please sign in to comment.