Write a SQL query to calculate the monthly active members who completed at least five workouts in the last 30 days for Peloton interactive.
Use the members and workouts tables. Treat a member as active when their membership status is active, and count only workouts with status completed. For each calendar month, evaluate the 30-day period ending on the last day of that month.
month and active_member_countmonth as YYYY-MM and order chronologically| Column | Type | Description |
|---|---|---|
| member_idPK | INT | Unique Peloton member identifier |
| member_name | VARCHAR(100) | Member display name |
| membership_status | VARCHAR(20) | Current membership status |
| Column | Type | Description |
|---|---|---|
| workout_idPK | INT | Unique workout identifier |
| member_id | INT | Member who performed the workout |
| completed_at | TIMESTAMP | Workout completion timestamp |
| workout_status | VARCHAR(20) | Workout lifecycle status |