Skip to content

Commit 90036df

Browse files
authored
Create 1412-find-the-quiet-students-in-all-exams.sql
1 parent d0fba6c commit 90036df

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Write your MySQL query statement below
2+
WITH cte AS(
3+
SELECT exam_id, exam.student_id, student_name, score, RANK() OVER(PARTITION BY exam_id ORDER BY score) rk1, RANK() OVER(PARTITION BY exam_id ORDER BY score DESC) rk2
4+
FROM exam LEFT JOIN student
5+
ON exam.student_id = student.student_id
6+
)
7+
8+
SELECT DISTINCT student_id, student_name
9+
FROM cte
10+
WHERE student_id NOT IN (SELECT student_id FROM cte WHERE rk1 = 1 or rk2 = 1)
11+
ORDER BY student_id;

0 commit comments

Comments
 (0)