Facebook wants a weekly retention curve showing how many users active in week N were also active in week N+1. Write a PostgreSQL query to calculate week-over-week retention.
week_start, compute:
retained_users / active_users, rounded to 4 decimal placesweek_start ascending.| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique event row identifier |
| user_id | INT | Facebook user identifier |
| event_name | VARCHAR(50) | Type of Facebook event |
| event_time | TIMESTAMP | Timestamp when the event occurred |
| device_type | VARCHAR(20) | Device used for the event |