Your question is SQL Rolling Three-Day Average. 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.
The BlueLabs Activity Insights surface needs a daily engagement trend for each user. Write a PostgreSQL query that calculates a rolling three-calendar-day average of activity.
user_id, user_name, activity_date, and the rounded average, ordered by user and date.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique user identifier |
| user_name | VARCHAR(100) | User display name |
| Column | Type | Description |
|---|---|---|
| interaction_idPK | INTEGER | Unique interaction identifier |
| user_id | INTEGER | References users.user_id |
| interaction_date | DATE | Calendar date of the interaction |
| activity_count | INTEGER | Number of activities in the interaction record |