Skip to content

leetcode 176 #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions solution/0100-0199/0176.Second Highest Salary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
### **SQL**

```

select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
SecondHighestSalary;
```

<!-- tabs:end -->
<!-- tabs:end -->
5 changes: 3 additions & 2 deletions solution/0100-0199/0176.Second Highest Salary/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
### **SQL**

```

select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
SecondHighestSalary;
```

<!-- tabs:end -->
<!-- tabs:end -->
2 changes: 2 additions & 0 deletions solution/0100-0199/0176.Second Highest Salary/Solution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
select (select distinct Salary from Employee order by Salary desc limit 1 offset 1) as
SecondHighestSalary;
11 changes: 9 additions & 2 deletions solution/0100-0199/0177.Nth Highest Salary/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@
### **SQL**

```

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set N = N-1;
RETURN (
# Write your MySQL query statement below.
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
);
END
```

<!-- tabs:end -->
<!-- tabs:end -->
11 changes: 9 additions & 2 deletions solution/0100-0199/0177.Nth Highest Salary/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,14 @@
### **SQL**

```

CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set N = N-1;
RETURN (
# Write your MySQL query statement below.
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
);
END
```

<!-- tabs:end -->
<!-- tabs:end -->
8 changes: 8 additions & 0 deletions solution/0100-0199/0177.Nth Highest Salary/Solution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
CREATE FUNCTION getNthHighestSalary(N INT) RETURNS INT
BEGIN
set N = N-1;
RETURN (
# Write your MySQL query statement below.
SELECT (SELECT DISTINCT Salary FROM Employee ORDER BY Salary DESC LIMIT 1 OFFSET N) AS SecondHighestSalary
);
END
6 changes: 5 additions & 1 deletion solution/0100-0199/0178.Rank Scores/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@
### **SQL**

```
select
Score,
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
from Scores order by Rank;

```

<!-- tabs:end -->
<!-- tabs:end -->
6 changes: 5 additions & 1 deletion solution/0100-0199/0178.Rank Scores/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
### **SQL**

```
select
Score,
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
from Scores order by Rank;

```

<!-- tabs:end -->
<!-- tabs:end -->
4 changes: 4 additions & 0 deletions solution/0100-0199/0178.Rank Scores/Solution.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
select
Score,
(select count(*) from (select distinct Score s from Scores) tmp where s>=Score) Rank
from Scores order by Rank;