Debate League Standings and Divisions
Problem
A school debate league records each squad's season in `squad_records`. Each row has a `squad_id`, a `squad_name`, the number of `rounds_debated`, and counts of `wins`, `splits`, and `losses`.
Scoring gives 3 points per win and 1 point per split; losses score nothing. For each squad compute its `squad_name`, total `score`, and `placement` — the ranking by score from highest to lowest using standard competition ranking (ties share a placement and the next placement skips positions). Then assign a `division` based on placement relative to the number of squads N: the top third (placement at or below CEIL(N * 0.33)) is 'Division A', the next third (placement at or below CEIL(N * 0.66)) is 'Division B', and the remainder is 'Division C'. A placement that lands exactly on a boundary goes to the higher division.
Order the result by `score` descending, then by `squad_name` ascending.
Tables
Example rows — the live problem includes the full dataset.
| squad_id | squad_name | rounds_debated | wins | splits | losses |
|---|---|---|---|---|---|
| 1 | Aristotle | 9 | 8 | 1 | 0 |
| 2 | Boyle | 9 | 6 | 1 | 2 |
| 3 | Curie | 9 | 5 | 2 | 2 |
Expected output
Your answer should return 5 rows with the columns squad_name, score, placement, division.
Starter code (SQL)
SELECT *
FROM squad_records;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