题目
![](https://img2020.cnblogs.com/blog/1469454/202107/1469454-20210708185648220-2011749070.png)
数据
![](https://img2020.cnblogs.com/blog/1469454/202107/1469454-20210708185730589-731918491.png)
结果
![](https://img2020.cnblogs.com/blog/1469454/202107/1469454-20210708185742731-813064956.png)
解答
1.
select distinct(Exam.student_id) as STUDENT_ID,
Student.student_name as STUDENT_NAME
from Exam
join Student on Student.student_id = Exam.student_id
![](https://img2020.cnblogs.com/blog/1469454/202107/1469454-20210708190103551-175244285.png)
2.结果、撇去最高、最低分。
select distinct(Exam.student_id) as STUDENT_ID,
Student.student_name as STUDENT_NAME
from Exam
join Student on Student.student_id = Exam.student_id
where Exam.student_id not in
(select distinct(student_id) from Exam
where (exam_id,score) in(select exam_id,max(score) as score from exam group by exam_id) # 实验最高分
or
(exam_id,score) in(select exam_id,min(score) as score from exam group by exam_id) # 实验最低分
)
order by Exam.student_id asc;
![](https://img2020.cnblogs.com/blog/1469454/202107/1469454-20210709085551247-625139768.png)