Skip to content

Commit ae53a67

Browse files
authored
Merge pull request doocs#282 from LjyYano/master
leetcode 176
2 parents ce09352 + e66c6e8 commit ae53a67

File tree

9 files changed

+48
-10
lines changed

9 files changed

+48
-10
lines changed

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
### **SQL**
3636

3737
```
38-
38+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
39+
SecondHighestSalary;
3940
```
4041

41-
<!-- tabs:end -->
42+
<!-- tabs:end -->

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@
5656
### **SQL**
5757

5858
```
59-
59+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
60+
SecondHighestSalary;
6061
```
6162

62-
<!-- tabs:end -->
63+
<!-- tabs:end -->
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
2+
SecondHighestSalary;

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@
3535
### **SQL**
3636

3737
```
38-
38+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
39+
BEGIN
40+
set N = N-1;
41+
RETURN (
42+
# Write your MySQL query statement below.
43+
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
44+
);
45+
END
3946
```
4047

41-
<!-- tabs:end -->
48+
<!-- tabs:end -->

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,14 @@
5656
### **SQL**
5757

5858
```
59-
59+
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
60+
BEGIN
61+
set N = N-1;
62+
RETURN (
63+
# Write your MySQL query statement below.
64+
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
65+
);
66+
END
6067
```
6168

62-
<!-- tabs:end -->
69+
<!-- tabs:end -->
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

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@
4343
### **SQL**
4444

4545
```
46+
select
47+
Score,
48+
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
49+
from Scores order by Rank;
4650
4751
```
4852

49-
<!-- tabs:end -->
53+
<!-- tabs:end -->

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@
7272
### **SQL**
7373

7474
```
75+
select
76+
Score,
77+
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
78+
from Scores order by Rank;
7579
7680
```
7781

78-
<!-- tabs:end -->
82+
<!-- tabs: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)