Chess Club Ladder Standings
Problem
Table: `Clubs`
```text
+-----------+----------+
| Column | Type |
+-----------+----------+
| club_id | int |
| club_name | varchar |
+-----------+----------+
club_id is the primary key.
```
Table: `Bouts`
```text
+-------------+------+
| Column | Type |
+-------------+------+
| bout_id | int |
| white_club | int |
| black_club | int |
| white_wins | int |
| black_wins | int |
+-------------+------+
bout_id is the primary key. Each row is a team match between two clubs: the
club playing White and the club playing Black, with the number of individual
boards each side won.
```
Score each club across all bouts using: **3 points** for winning a bout (more board wins than the opponent), **1 point** for a tie (equal board wins), and **0 points** for a loss. A club that played no bouts has 0 points.
Return `club_id`, `club_name`, `standing_points`, ordered by `standing_points` descending, then `club_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
| club_id | club_name |
|---|---|
| 10 | Knight Owls |
| 20 | Rook Riders |
| 30 | Bishop Brigade |
| bout_id | white_club | black_club | white_wins | black_wins |
|---|---|---|---|---|
| 1 | 10 | 20 | 3 | 0 |
| 2 | 30 | 10 | 2 | 2 |
| 3 | 10 | 50 | 5 | 1 |
Expected output
Your answer should return 5 rows with the columns club_id, club_name, standing_points.
Starter code (SQL)
SELECT *
FROM Clubs;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