Your question is Consecutive Activity Using Lead Lag. 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.
Publicis Groupe analysts need to identify consecutive days of activity across a digital platform. Write a PostgreSQL query that removes duplicate same-day interactions, uses LAG and LEAD to compare adjacent activity dates, and returns every activity day that belongs to a consecutive-day sequence.
interaction_timestamp is NULL.LAG and LEAD partitioned by user to identify activity days adjacent to another activity day.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| full_name | VARCHAR(100) | User's full name |
| platform | VARCHAR(50) | Publicis Groupe platform used by the user |
| Column | Type | Description |
|---|---|---|
| interaction_idPK | INT | Unique interaction identifier |
| user_id | INT | User associated with the interaction |
| interaction_timestamp | TIMESTAMP | Timestamp when the interaction occurred |