Members With Both Plans
Problem
A boutique gym sells passes under several plan names. Find every distinct `member_id` that has purchased at least one **Yoga** pass and at least one **Spin** pass. Return one row per qualifying member in the column `member_id`, ordered by `member_id` ascending.
Tables
Example rows — the live problem includes the full dataset.
GymPasses
| pass_id | member_id | plan_name |
|---|---|---|
| 11 | 501 | Yoga |
| 12 | 501 | Pilates |
| 13 | 501 | Spin |
Expected output
Your answer should return 2 rows with the columns member_id.
Starter code (SQL)
SELECT *
FROM GymPasses;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