3.35
Using the university schema, write an SQL query to find section(s) with maximum enrollment. The result columns should appear in the order “courseid, secid, year, semester, num”. (It may be convenient to use the with construct.)
WITH section_student_frequency(courseid, secid, year, semester, num) AS (
SELECT course_id, sec_id, year, semester, COUNT(DISTINCT ID)
FROM takes
GROUP BY course_id, sec_id, year, semester
)SELECT *
FROM section_student_frequency
WHERE num = (SELECT MAX(num) FROM section_student_frequency);