Arity analyzes monthly mileage from connected-vehicle telemetry to support driver risk and usage insights. Write a PostgreSQL query that calculates a running three-month moving average of mileage for each active driver.
is_active value is TRUE.user_id and order each driver's records chronologically.NULL mileage values should be ignored by AVG.Assume arity_monthly_mileage contains at most one row per driver per calendar month.
| Column | Type | Description |
|---|---|---|
| user_idPK | INTEGER | Unique driver identifier |
| user_name | VARCHAR(100) | Driver display name |
| is_active | BOOLEAN | Whether the driver is currently active |
| Column | Type | Description |
|---|---|---|
| mileage_idPK | INTEGER | Unique mileage record identifier |
| user_id | INTEGER | References arity_users.user_id |
| month_start | DATE | First calendar day of the measurement month |
| miles_driven | NUMERIC(10,1) | Total miles driven during the month |