Leetcode 1412. 查找成绩处于中游的学生
2021-12-24 本文已影响0人
七齐起器
https://leetcode-cn.com/problems/find-the-quiet-students-in-all-exams/
select a.student_id,b.student_name from (
select a.student_id
,case when count(a.score)=sum(case when a.score>b.s1 and a.score<b.s2 then 1 else 0 end) then 1 else 0 end tag
from Exam a left join (
select exam_id,min(score)s1,max(score)s2
from Exam
group by exam_id
)b on a.exam_id=b.exam_id
group by a.student_id
)a left join Student b on a.student_id=b.student_id
where a.tag=1
order by a.student_id
1412.png