Poll Participation Rate
Problem
A community app runs polls. `Resident` lists everyone who could vote, and `Ballot` records which residents voted in which poll.
`Resident`:
- `resident_id` (int), `resident_name` (varchar)
`Ballot`:
- `poll_id` (int), `resident_id` (int) — together unique
For each poll, report what share of all residents voted in it, as a value out of 100 rounded to **two decimals**. Order by `participation` descending; break ties by `poll_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
| resident_id | resident_name |
|---|---|
| 6 | Noor |
| 2 | Bram |
| 7 | Kiana |
| poll_id | resident_id |
|---|---|
| 315 | 6 |
| 309 | 2 |
| 308 | 2 |
Expected output
Your answer should return 5 rows with the columns poll_id, participation.
Starter code (SQL)
SELECT *
FROM Resident;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