Streaming Cohorts on the Calendar

Streaming Cohorts on the Calendar

You are analyzing the launch of Vela Stream, a subscription video service. Marketing wants to compare viewers activated on different days, weeks, and months, so every subscriber needs three calendar cohort labels. The subscriptions table stores the subscription activation timestamp. A weekly cohort starts on Monday, and a monthly cohort starts on the first calendar day of the month. Ignore rows where activated_at IS NULL. For every subscriber with a known activation time, determine: - the activation day; - the Monday of the activation week; - the first day of the activation month. Return: - subscriber_id; - cohort_day; - cohort_week; - cohort_month. All three cohort columns must be dates displayed as YYYY-MM-DD. Sort by subscriber_id ascending. Return exactly one row per subscriber.

Expected output sample

This is what a correct answer looks like — its row count is its own, it doesn't have to match the schema tables. Your answer must use the same column names as this sample — alias them with AS if needed.

subscriber_idcohort_daycohort_weekcohort_month
3012025-12-312025-12-292025-12-01
3022026-01-012025-12-292026-01-01
3032026-01-042025-12-292026-01-01
PostgreSQLv16

Your query result will appear here

Focus radio
Paused · SomaFM · Fluid