Students Per Major, Undeclared Included
hardQuestion 15Count the students in each major, and keep the four undeclared students as their own group. Return major (the department name, NULL for students with no major) and students (the count). Sort by students descending, then by major ascending; SQLite sorts NULL before any text, so the undeclared group comes first among the fours.
Expected result
+------------------+----------+ | major | students | +------------------+----------+ | Computer Science | 8 | | Mathematics | 5 | | NULL | 4 | | Biology | 4 | | Business | 4 | | English | 4 | | Fine Arts | 1 | +------------------+----------+ 7 rows
Hints4 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 under the question.