CJCoding With Joseph
15free / daySign inCreate account

Cities With More Than Three Students

Which home cities have more than three students? Return city and students (the count), only for cities whose count is above 3, sorted by students descending and then by city. The filter must apply to the count, so it cannot go in a WHERE clause.

Expected result:

+-------------+----------+
| city        | students |
+-------------+----------+
| Toronto     |        8 |
| Ottawa      |        5 |
| Hamilton    |        4 |
| Mississauga |        4 |
+-------------+----------+
4 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.