3.34

Using the university schema, write an SQL query to find the number of students in each section. The result columns should appear in the order “course_id, sec_id, year,semester,num”. You do not need to output sections with 0 students.


SELECT course_id, sec_id, year, semester, COUNT(DISTINCT ID) AS num
FROM takes
GROUP BY course_id, sec_id, year, semester;