← Back to Aggregates & GROUP BY
Question 10
Students Per Department
Students Per Department
For each department, count the students who have declared it as their major. Returndepartment(the department'sname) andstudents(the count), sorted bydepartment. Students with no major are left out here; every department has at least one student.
Expected result:
+------------------+----------+ | department | students | +------------------+----------+ | Biology | 4 | | Business | 4 | | Computer Science | 8 | | English | 4 | | Fine Arts | 1 | | Mathematics | 5 | +------------------+----------+ 6 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.