Festival Category Wins
Problem
A film festival hands out four awards each year. Each award column stores the `director_id` of the winner.
```
Director
+-------------+---------+
| Column | Type |
+-------------+---------+
| director_id | int |
| director | varchar |
+-------------+---------+
director_id is the primary key.
AwardYear
+-------------+------+
| Column | Type |
+-------------+------+
| edition | int |
| best_picture | int |
| best_drama | int |
| best_comedy | int |
| best_short | int |
+-------------+------+
edition is the primary key. Each award column holds the director_id who won that award that edition.
```
Report how many festival awards each director has won. Exclude directors who never won anything.
Return `director_id`, `director`, and `total_wins`, in any order.
Tables
Example rows — the live problem includes the full dataset.
| director_id | director |
|---|---|
| 1 | Vega |
| 2 | Romano |
| 3 | Okafor |
| edition | best_picture | best_drama | best_comedy | best_short |
|---|---|---|---|---|
| 2018 | 1 | 1 | 1 | 1 |
| 2019 | 1 | 1 | 2 | 2 |
| 2020 | 2 | 1 | 2 | 2 |
Expected output
Your answer should return 2 rows with the columns director_id, director, total_wins.
Starter code (SQL)
SELECT *
FROM Director;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