題目 19:查詢每門課程被選修的學生數
SELECT courseid,COUNT(studentid) FROM student_score GROUP BY courseid;
運行:
練習題20 :查詢出只選修兩門課程的學生學號和姓名
SELECT student.*, r.a FROM student,
(SELECT studentid,COUNT(courseid) AS a FROM student_score GROUP BY student_score.studentid)r
WHERE r.a =2 AND student.id = r.studentid ;
運行: