File tree 3 files changed +84
-2
lines changed
solution/1400-1499/1412.Find the Quiet Students in All Exams
3 files changed +84
-2
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,34 @@ Result 表:
97
97
### ** SQL**
98
98
99
99
``` 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 ;
101
128
```
102
129
103
130
<!-- tabs:end -->
Original file line number Diff line number Diff line change @@ -94,7 +94,34 @@ So, we only return the information of Student 2.
94
94
### ** SQL**
95
95
96
96
``` 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 ;
98
125
```
99
126
100
127
<!-- tabs:end -->
Original file line number Diff line number Diff line change
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 ;
You can’t perform that action at this time.
0 commit comments