Skip to content

Commit 00e9e40

Browse files
committed
feat: add solution to lc problem: No.1412
No.1412.Find the Quiet Students in All Exams
1 parent c5fbc01 commit 00e9e40

File tree

3 files changed

+84
-2
lines changed

3 files changed

+84
-2
lines changed

solution/1400-1499/1412.Find the Quiet Students in All Exams/README.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,34 @@ Result 表:
9797
### **SQL**
9898

9999
```sql
100-
100+
# Write your MySQL query statement below
101+
with t as (
102+
select
103+
*,
104+
rank() over(
105+
partition by exam_id
106+
order by
107+
score desc
108+
) rk1,
109+
rank() over(
110+
partition by exam_id
111+
order by
112+
score asc
113+
) rk2
114+
from
115+
Exam
116+
)
117+
select
118+
t.student_id,
119+
student_name
120+
from
121+
t
122+
join Student s on t.student_id = s.student_id
123+
group by
124+
t.student_id
125+
having
126+
sum(rk1 = 1) = 0
127+
and sum(rk2 = 1) = 0;
101128
```
102129

103130
<!-- tabs:end -->

solution/1400-1499/1412.Find the Quiet Students in All Exams/README_EN.md

+28-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,34 @@ So, we only return the information of Student 2.
9494
### **SQL**
9595

9696
```sql
97-
97+
# Write your MySQL query statement below
98+
with t as (
99+
select
100+
*,
101+
rank() over(
102+
partition by exam_id
103+
order by
104+
score desc
105+
) rk1,
106+
rank() over(
107+
partition by exam_id
108+
order by
109+
score asc
110+
) rk2
111+
from
112+
Exam
113+
)
114+
select
115+
t.student_id,
116+
student_name
117+
from
118+
t
119+
join Student s on t.student_id = s.student_id
120+
group by
121+
t.student_id
122+
having
123+
sum(rk1 = 1) = 0
124+
and sum(rk2 = 1) = 0;
98125
```
99126

100127
<!-- tabs:end -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Write your MySQL query statement below
2+
with t as (
3+
select
4+
*,
5+
rank() over(
6+
partition by exam_id
7+
order by
8+
score desc
9+
) rk1,
10+
rank() over(
11+
partition by exam_id
12+
order by
13+
score asc
14+
) rk2
15+
from
16+
Exam
17+
)
18+
select
19+
t.student_id,
20+
student_name
21+
from
22+
t
23+
join Student s on t.student_id = s.student_id
24+
group by
25+
t.student_id
26+
having
27+
sum(rk1 = 1) = 0
28+
and sum(rk2 = 1) = 0;

0 commit comments

Comments
 (0)