Promotion-Track Baristas
Problem
A coffee chain runs a weekly customer-vote and records the top three baristas each week.
```
WeeklyVote
+-------------+------+
| Column | Type |
+-------------+------+
| week_no | int |
| top_pick | int |
| second_pick | int |
| third_pick | int |
+-------------+------+
week_no is the primary key. Each column holds the barista_id placed in that rank that week.
Barista
+-------------+---------+
| Column | Type |
+-------------+---------+
| barista_id | int |
| email | varchar |
| name | varchar |
+-------------+---------+
barista_id is the primary key.
```
A barista is on the **promotion track** if EITHER:
- they placed in the top three (any rank) in **three or more consecutive weeks**, OR
- they were the `top_pick` in **three or more** different weeks.
Report the `name` and `email` of every promotion-track barista, in any order.
Tables
Example rows — the live problem includes the full dataset.
| week_no | top_pick | second_pick | third_pick |
|---|---|---|---|
| 190 | 1 | 2 | 3 |
| 191 | 2 | 3 | 1 |
| 192 | 3 | 1 | 2 |
| barista_id | name | |
|---|---|---|
| 1 | mara@brewco.test | Mara |
| 2 | devi@brewco.test | Devi |
| 3 | tom@brewco.test | Tom |
Expected output
Your answer should return 3 rows with the columns name, email.
Starter code (SQL)
SELECT *
FROM WeeklyVote;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