← Back to Aggregates & GROUP BY
Question 11
Busiest Courses First
Busiest Courses First
Count the enrollments in each course. Returncodeandenrollments(the count), with the busiest course first: sort byenrollmentsdescending, then bycodeto break ties. Only courses with at least one enrollment appear, so ART140 is missing.
Expected result:
+---------+-------------+ | code | enrollments | +---------+-------------+ | MATH110 | 14 | | ENG101 | 12 | | CS230 | 11 | | BUS150 | 10 | | CS101 | 10 | | CS201 | 6 | | MATH220 | 6 | | BIO120 | 5 | | BIO305 | 4 | | CS310 | 4 | +---------+-------------+ (showing 10 of 13 rows)
Hints3 available
Sign in to use hintsTopics:
Aggregates & GROUP BY
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sel, ins, desc)
Results
Run your SQL to see every statement's output here, then how it compares with the expected answer.
Not sure what is in a table? SHOW TABLES lists them and DESCRIBE students shows the columns — or open the database browser on the left.