Your question is Aggregate Drives From Telematics. Start with the requirements and the three 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.
Geotab analysts need a monthly view of completed fleet drives from telematics data. Write a PostgreSQL query that aggregates qualifying drives for active vehicles during Q1 2025.
NULL when total distance is zero.| Column | Type | Description |
|---|---|---|
| vehicle_idPK | INT | Unique vehicle identifier |
| vehicle_name | VARCHAR(100) | Fleet vehicle name |
| region | VARCHAR(50) | Operating region |
| status | VARCHAR(20) | Vehicle lifecycle status |
| Column | Type | Description |
|---|---|---|
| drive_idPK | INT | Unique drive identifier |
| vehicle_id | INT | Vehicle associated with the drive |
| started_at | TIMESTAMP | Drive start timestamp |
| ended_at | TIMESTAMP | Drive end timestamp |
| distance_km | NUMERIC(10,2) | Distance traveled in kilometers |
| drive_status | VARCHAR(20) | Drive processing status |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique safety-event identifier |
| drive_id | INT | Drive associated with the event |
| event_type | VARCHAR(40) | Safety event classification |