Write a SQL query using SQL window functions to compute rolling 7-day averages of disengagement rates across different vehicle cohorts and geofences.
Calculate rates from engagement-level records and include only records with valid cohort and geofence references.
vehicle_cohort, geofence, activity_date, daily_disengagement_rate, and rolling_7_day_avgvehicle_cohort, geofence, and activity_date ascending| Column | Type | Description |
|---|---|---|
| engagement_idPK | INT | Unique engagement record identifier |
| cohort_id | INT | Vehicle cohort reference |
| geofence_id | INT | Geofence reference |
| activity_date | DATE | Date of the engagement |
| disengaged | BOOLEAN | Whether the vehicle disengaged during the engagement |
| Column | Type | Description |
|---|---|---|
| cohort_idPK | INT | Unique vehicle cohort identifier |
| cohort_name | VARCHAR(100) | Vehicle cohort label |
| Column | Type | Description |
|---|---|---|
| geofence_idPK | INT | Unique geofence identifier |
| geofence_name | VARCHAR(100) | Geofence label |