Your question is Window Functions for Moving Averages. 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.
Waymo One operations teams monitor rider wait times across operational territories. Write a PostgreSQL query that calculates a rolling average of daily completed-ride wait times for each territory.
AVG should ignore NULL wait values.| Column | Type | Description |
|---|---|---|
| territory_idPK | INTEGER | Operational territory identifier |
| territory_name | VARCHAR(80) | Waymo One operational territory name |
| Column | Type | Description |
|---|---|---|
| wait_idPK | INTEGER | Wait-time record identifier |
| territory_id | INTEGER | Associated operational territory |
| service_date | DATE | Date of the ride |
| wait_minutes | NUMERIC(6,2) | Rider wait time in minutes |
| ride_status | VARCHAR(20) | Ride lifecycle status |