Leetcode 1412. 查找成绩处于中游的学生

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
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容