Write a query using SQL window functions to calculate running 30-day active user retention cohorts across different subscription tiers.
Use the provided users, subscriptions, and activity_events tables. Treat each user's signup month as the cohort, use the non-ended subscription at signup, and evaluate activity during signup day through day 30.
Output
- One row per subscription tier, signup cohort month, and checkpoint day 0, 7, 14, 21, 28, or 30.
- Return
tier, cohort_month, days_since_signup, cohort_size, running_active_users, and retention_rate_pct.
- Include cohorts with no qualifying activity, order by
tier, cohort_month, and days_since_signup.
Output details
- Order
tier, cohort_month, and days_since_signup in ascending order.
- Round
retention_rate_pct to two decimal places.
- Treat activity timestamps at or after signup and before signup plus 31 days as qualifying.
- Represent cohorts without qualifying activity with zero
running_active_users and 0.00 retention_rate_pct.