AnalystPath

Members Active in Two Quarters

SQLEasyJunior level~15 min

Problem

A gym tracks every class booking. Each booking links a member to a class, and each class has a credit cost.

Write a query to find the members who spent **at least 50 credits in Q1 2023 (Jan-Mar) AND at least 50 credits in Q2 2023 (Apr-Jun)**. The credits for a booking are `seats * cost`.

Return `member_id` and `member_name`. Order does not matter.

Tables

Example rows — the live problem includes the full dataset.

members
member_idmember_namehome_city
1PriyaAustin
2DiegoLima
3HanaOsaka
classes
class_idclass_titlecost
10Spin150
20Yoga5
30Boxing22
bookings
booking_idmember_idclass_idbooked_onseats
11102023-02-101
21202023-04-011
31302023-04-083

Expected output

Your answer should return 1 row with the columns member_id, member_name.

Starter code (SQL)

SELECT *
FROM members;

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