Member Count per Club
Problem
Table: `Member`
```text
+-----------+---------+
| Column | Type |
+-----------+---------+
| member_id | int |
| member_name| varchar|
| year_level| varchar |
| club_id | int |
+-----------+---------+
member_id is the primary key.
```
Table: `Club`
```text
+---------+---------+
| Column | Type |
+---------+---------+
| club_id | int |
| club_name| varchar|
+---------+---------+
club_id is the primary key.
```
For **every** club in the Club table (including clubs that currently have no members), report the `club_name` and the number of members who belong to it as `member_count`. Sort by `member_count` descending, then by `club_name` ascending.
Tables
Example rows — the live problem includes the full dataset.
| member_id | member_name | year_level | club_id |
|---|---|---|---|
| 10 | Aya | Y1 | 1 |
| 11 | Ben | Y2 | 1 |
| 12 | Cole | Y1 | 2 |
| club_id | club_name |
|---|---|
| 1 | Chess |
| 2 | Robotics |
| 3 | Debate |
Expected output
Your answer should return 3 rows with the columns club_name, member_count.
Starter code (SQL)
SELECT *
FROM Member;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock