希望能有点帮助,分两段执行。
select b.name 'course_name', a.number 'num_max', a.student_id 'student_id', c.name 'student_name' from score a,course b,student c
where a.number = (select max(number) from score b where a.course_id=b.course_id)
and a.course_id=b.course_id
and a.student_id=c.student_id;
select b.name 'course_name', a.number 'num_min', a.student_id 'student_id', c.name 'student_name' from score a,course b,student c
where a.number = (select min(number) from score b where a.course_id=b.course_id)
and a.course_id=b.course_id
and a.student_id=c.student_id;
本文提供了一种SQL查询方法,用于从成绩表中找出每个课程的最高分和最低分及其对应的学生信息。通过两次SELECT语句分别实现了最大值和最小值的检索。
10万+

被折叠的 条评论
为什么被折叠?



