Subscription Commerce Analytics Path · Mission 6 of 25Medium

Monthly active subscriber trend

First DATE_TRUNC. Practice rolling daily snapshots up to a monthly granularity, COUNT(DISTINCT) across many snapshot rows per subscription, and producing a time-series the BI team can chart directly.

The Brief

Devon ParkSenior Analyst, Lifecyclesubscription-ops

Mira's deck for the leadership offsite needs a monthly active subscriber trend. From fact_subscription_snapshots, group by month (DATE_TRUNC the snapshot_date) and count distinct subscriptions where state = 'active'. Two columns: month, active_subs. Sort month ascending. Snapshot window is ~7 months (2025-09-13 → 2026-03-31), so expect 7 month buckets — the first one will be a partial month.

You'll practice

date_truncGROUP BYORDER BY

Tables & columns available

fact_subscription_snapshotsfact7 columns
ColumnTypeKey
snapshot_dateTEXTPK
subscription_idINTPKFK → fact_subscriptions
customer_idINTFK → dim_customers
stateTEXT
plan_idINTFK → dim_plans
mrrREAL
paused_untilTEXT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

DATE_TRUNC('month', snapshot_date::date) returns the first of the month as a date. snapshot_date is TEXT — cast it to date first.

Hint 2

COUNT(DISTINCT subscription_id) is essential here. Without DISTINCT you'd be counting subscription-day pairs across the month (~30x the actual sub count).

Hint 3

GROUP BY DATE_TRUNC('month', snapshot_date::date) and ORDER BY the same expression. Or alias the trunc and order by the alias.