File tree 3 files changed +13
-1
lines changed
database/NthHighestSalary 3 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -334,4 +334,5 @@ All solutions will be accepted!
334
334
| 176| [ Second Highest Salary] ( https://leetcode-cn.com/problems/second-highest-salary/description/ ) | [ mysql] ( ./database/SecondHighestSalary ) | Easy|
335
335
| 626| [ Exchange Seats] ( https://leetcode-cn.com/problems/exchange-seats/description/ ) | [ mysql] ( ./database/ExchangeSeats ) | Medium|
336
336
| 178| [ Rank Scores] ( https://leetcode-cn.com/problems/rank-scores/description/ ) | [ mysql] ( ./database/RankScore ) | Medium|
337
- | 180| [ Consecutive Numbers] ( https://leetcode-cn.com/problems/consecutive-numbers/description/ ) | [ mysql] ( ./database/ConsecutiveNumbers ) | Medium|
337
+ | 180| [ Consecutive Numbers] ( https://leetcode-cn.com/problems/consecutive-numbers/description/ ) | [ mysql] ( ./database/ConsecutiveNumbers ) | Medium|
338
+ | 177| [ Nth Highest Salary] ( https://leetcode-cn.com/problems/nth-highest-salary/description/ ) | [ mysql] ( ./database/NthHighestSalary ) | Medium|
Original file line number Diff line number Diff line change
1
+ # Nth Highest Salary
2
+ We can solve this problem by MYSQL FUNCTION
Original file line number Diff line number Diff line change
1
+ CREATE FUNCTION getNthHighestSalary (N INT ) RETURNS INT
2
+ BEGIN
3
+ DECLARE M INT ;
4
+ SET M = N - 1 ;
5
+ RETURN (
6
+ # Write your MySQL query statement below.
7
+ select distinct Salary from Employee order by Salary desc limit M, 1
8
+ );
9
+ END
You can’t perform that action at this time.
0 commit comments