AnalystPath

Promotion-Track Baristas

SQLMediumMid level~15 min

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.

WeeklyVote
week_notop_picksecond_pickthird_pick
190123
191231
192312
Barista
barista_idemailname
1mara@brewco.testMara
2devi@brewco.testDevi
3tom@brewco.testTom

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

Related SQL questions