Committed Gym Members
Problem
A gym logs every member visit, marked either 'checkin' (they showed up) or 'noshow' (a booked slot they missed). A member counts as committed when they meet all of the following: at least 3 check-ins, an active span of at least 30 days between their first and last logged visit, and a no-show rate below 20% (no-shows divided by all logged visits). Return the member_id of every committed member, ordered by member_id ascending.
Tables
Example rows — the live problem includes the full dataset.
| visit_id | member_id | visit_date | visit_kind |
|---|---|---|---|
| 1 | 201 | 2024-01-05 | checkin |
| 2 | 201 | 2024-01-20 | checkin |
| 3 | 201 | 2024-02-10 | checkin |
Expected output
Your answer should return 1 row with the columns member_id.
Starter code (SQL)
SELECT *
FROM member_visits;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