CJCoding With Joseph
15free / daySign inCreate account

Students Per City

Count how many students come from each home city. Return city and students (the count), one row per distinct city, sorted by city alphabetically. Every city appears, including the three with a single student.

Expected result:

+-------------+----------+
| city        | students |
+-------------+----------+
| Guelph      |        1 |
| Hamilton    |        4 |
| Kingston    |        3 |
| London      |        3 |
| Mississauga |        4 |
| Ottawa      |        5 |
| Toronto     |        8 |
| Waterloo    |        1 |
| Windsor     |        1 |
+-------------+----------+
9 rows
Hints3 available
Topics:
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.