题目32:求每门课程的学生人数
分析: 这个直接是group by 然后 count
SELECT courseid, COUNT(studentid) FROM student_score GROUP BY courseid
题目33:查询选修「张三」老师所授课程的学生中,成绩最高的学生信息及其成绩
这个是直接查出 「张三」老师 授课的是哪门课程id,然后再查这个课程的成绩 按照score 排序 取值 limit 1
SELECT student.* ,student_score.score FROM student_course,student_score,teacher,student WHERE
teacher.id = student_course.teacherid
AND teacher.teacher_name = '张三'
AND student_course.id = student_score.courseid
AND student.id = student_score.studentid
ORDER BY score DESC LIMIT 1
来源:oschina
链接:https://my.oschina.net/u/4270180/blog/3425495