Skip to content

Commit 9f18c0a

Browse files
committed
leetcode 177, 178
1 parent 128e99d commit 9f18c0a

File tree

7 files changed

+41
-19
lines changed

7 files changed

+41
-19
lines changed

solution/0100-0199/0176.Second Highest Salary/README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@
4646

4747
```
4848

49-
### **...**
49+
### **sql**
5050
```
51-
51+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
52+
SecondHighestSalary;
5253
```
5354

54-
<!-- tabs:end -->
55+
<!-- tabs:end -->

solution/0100-0199/0176.Second Highest Salary/README_EN.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,10 @@
6565

6666
```
6767

68-
### **...**
68+
### **sql**
6969
```
70-
70+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
71+
SecondHighestSalary;
7172
```
7273

73-
<!-- tabs:end -->
74+
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
1+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
22
SecondHighestSalary;

solution/0100-0199/0177.Nth Highest Salary/README.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,16 @@
4646

4747
```
4848

49-
### **...**
49+
### **sql**
5050
```
51-
51+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
52+
BEGIN
53+
set N = N-1;
54+
RETURN (
55+
# Write your MySQL query statement below.
56+
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
57+
);
58+
END
5259
```
5360

54-
<!-- tabs:end -->
61+
<!-- tabs:end -->

solution/0100-0199/0177.Nth Highest Salary/README_EN.md

+10-3
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,16 @@
6565

6666
```
6767

68-
### **...**
68+
### **sql**
6969
```
70-
70+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
71+
BEGIN
72+
set N = N-1;
73+
RETURN (
74+
# Write your MySQL query statement below.
75+
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
76+
);
77+
END
7178
```
7279

73-
<!-- tabs:end -->
80+
<!-- tabs:end -->

solution/0100-0199/0178.Rank Scores/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,12 @@
5454

5555
```
5656

57-
### **...**
57+
### **sql**
5858
```
59-
59+
select
60+
Score,
61+
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
62+
from Scores order by Rank;
6063
```
6164

62-
<!-- tabs:end -->
65+
<!-- tabs:end -->

solution/0100-0199/0178.Rank Scores/README_EN.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,12 @@
8181

8282
```
8383

84-
### **...**
84+
### **sql**
8585
```
86-
86+
select
87+
Score,
88+
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
89+
from Scores order by Rank;
8790
```
8891

89-
<!-- tabs:end -->
92+
<!-- tabs:end -->

0 commit comments

Comments
 (0)