Your question is Rolling 30-Day Retention Query. Start with the requirements and the two tables on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
EvenUp's marketing team wants to compare how effectively acquisition channels drive early customer engagement. Using customer acquisition records and subsequent activity events, calculate 30-day retention for each acquisition-date and channel cohort.
Assume a customer is retained when they generate at least one activity event strictly after acquisition and before 30 days have elapsed. Include cohorts with zero retained customers, and label missing acquisition channels as Unknown.
LEFT JOIN so cohorts with no retained customers remain in the output.| Column | Type | Description |
|---|---|---|
| customer_idPK | INTEGER | Unique customer identifier |
| acquired_at | TIMESTAMPTZ | Timestamp when the customer was acquired |
| acquisition_channel | VARCHAR(50) | Marketing channel credited with acquisition |
| Column | Type | Description |
|---|---|---|
| event_idPK | INTEGER | Unique activity event identifier |
| customer_id | INTEGER | Customer associated with the event |
| event_at | TIMESTAMPTZ | Timestamp when the activity occurred |
| event_type | VARCHAR(50) | Type of customer activity |