Your question is Rolling 30-Day Active Users. Start with the requirements and the one table 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.
BCG wants to monitor engagement across its internal digital products and analytics surfaces. Using a raw event log, calculate the number of unique users active during the trailing 30 calendar days for each date in the event range.
Write a PostgreSQL query that produces one row per calendar date from the minimum through maximum event date.
user_id only once within each 30-day window.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event identifier |
| user_id | INT | User who generated the event |
| event_timestamp | TIMESTAMP | Timestamp when the event occurred |
| event_type | VARCHAR(30) | Type of user event |