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; each subscriber has exactly one row in it — subscriber_id is the primary key. 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.

A ordem das linhas importa

PostgreSQLv16
Entre para enviar

O resultado da sua consulta aparecerá aqui

Focus radio
Paused · SomaFM · Fluid