Skip to content

Commit 128e99d

Browse files
committed
leetcode 177, 178
1 parent 62fae1c commit 128e99d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
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 (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
7+
);
8+
END
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
select
2+
Score,
3+
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
4+
from Scores order by Rank;

0 commit comments

Comments
 (0)