題目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