Your question is Rolling Retention in SQL. 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.
Cisco Webex analytics needs a daily engagement report for a selected reporting period. Write a PostgreSQL query that aggregates daily active users and calculates rolling seven-day retention metrics.
session event on each reporting date as daily_active_users.session event during the current date and six preceding dates as rolling_7d_active_users.rolling_7d_retention_pct as rolling seven-day active users divided by users enrolled on or before the reporting date.NULL enrollment date and events that are not session events.| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique Webex user identifier |
| user_name | VARCHAR(100) | User display name |
| enrolled_at | DATE | Date the user became eligible |
| team | VARCHAR(80) | Cisco team associated with the user |
| Column | Type | Description |
|---|---|---|
| event_idPK | INTEGER | Unique activity event identifier |
| user_id | INTEGER | Webex user who generated the event |
| event_at | TIMESTAMP | Timestamp when the activity occurred |
| event_type | VARCHAR(30) | Activity type |