How would you write a query to find the average fuel consumption per trip for a specific fleet, given a set of vehicle telemetry tables at Volvo Group?
For the sample data, calculate the result for fleet_id = 101. Include only trips with at least one valid fuel-consumption reading.
fleet_id and average_fuel_consumption_liters.| Column | Type | Description |
|---|---|---|
| vehicle_idPK | INT | Unique vehicle identifier |
| fleet_id | INT | Fleet assigned to the vehicle |
| Column | Type | Description |
|---|---|---|
| trip_idPK | INT | Unique trip identifier |
| vehicle_id | INT | Vehicle that completed the trip |
| trip_date | DATE | Date on which the trip occurred |
| Column | Type | Description |
|---|---|---|
| telemetry_idPK | INT | Unique telemetry record identifier |
| trip_id | INT | Trip associated with the telemetry reading |
| fuel_consumed_liters | NUMERIC(10,2) | Fuel consumed in liters for the telemetry interval |