题目:26:查询平均成绩大于等于 85 的所有学生的学号、姓名和平均成绩
分析:这个应该是根据student 进行分组 group by 再根据 having >= 85 进行过滤,然后在关联student 信息表,拿到学生的基本信息
SELECT student.id, student.stdentname,AVG(student_score.score) AS a FROM student_score, student
WHERE student.id = student_score.studentid
GROUP BY student_score.studentid HAVING a>=85
题目27:查询课程名称为「数学」,且分数低于 60 的学生姓名和分数
分析: 这个应该是多表查询 student , student_course, student_score 三个表查询
SELECT student.id,student_course.coursename, student.stdentname,student_score.score FROM student_course, student_score,student
WHERE student_course.coursename = "数学" AND student_course.id = student_score.courseid AND student_score.score<60
AND student_score.studentid = student.id
原文地址:https://www.cnblogs.com/yuanyuan2017/p/11376305.html
时间: 2024-12-28 10:35:39