SparkBeyond wants to compare how users acquired in different months continue using the SparkBeyond platform. A qualifying activity is an insight_generated event on any SparkBeyond surface.
Write a PostgreSQL query that calculates monthly retention by signup cohort and compares each cohort's retention rate with the previous cohort for the same lifecycle month.
users.signup_at.LAG window function to show the prior cohort's retention percentage and the percentage-point difference.insight_generated events, exclude activity before signup, and sort chronologically.| Column | Type | Description |
|---|---|---|
| user_idPK | INT | Unique user identifier |
| signup_at | TIMESTAMP | Timestamp when the user joined SparkBeyond |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique product event identifier |
| user_id | INT | User who generated the event |
| event_at | TIMESTAMP | Timestamp when the event occurred |
| event_name | VARCHAR(40) | Name of the SparkBeyond product event |
| surface | VARCHAR(40) | SparkBeyond surface where the event occurred |