AnalystPath

Committed Gym Members

SQLMediumMid level~15 min

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.

member_visits
visit_idmember_idvisit_datevisit_kind
12012024-01-05checkin
22012024-01-20checkin
32012024-02-10checkin

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

Related SQL questions