mysql经典练习每天10道题之三

21、查询平均成绩大于等于85的所有学生的学号、姓名和平均成绩
SELECT a.s_id,a.s_name,b.avg
from student a
join (SELECT s_id,avg(s_score) as avg from score GROUP BY s_id having avg(s_score)>=85) as b
on a.s_id =b.s_id ;
在这里插入图片描述
SELECT a.s_id,a.s_name,avg(score.s_score)
from student a ,score
where a.s_id=score.s_id GROUP BY a.s_id having avg(score.s_score)>=85;

21、查询课程名称为”数学”,且分数低于60的学生姓名和分数
SELECT a.s_name,b.s_score
from student a,score b
where a.s_id =b.s_id and (SELECT c_id from course where c_name =‘数学’)=b.c_id
and b.s_score < 60;

在这里插入图片描述
SELECT a.s_name,b.s_score
from student a
join score b on a.s_id = b.s_id
and b.c_id =(SELECT c_id from course where c_name =‘数学’)
and b.s_score<60;

22、

猜你喜欢

转载自blog.csdn.net/SYSZ520/article/details/97393948