SUM multiple cost columns to compute total spend
I'm closing the books for the period. Give me total freight spend across all shipments: sum `freight_cost` as `total_linehaul`, sum `fuel_surcharge` as `total_fuel`, sum `accessorial_cost` as `total_accessorial`, and also compute the grand total as `total_spend`. One row, four columns.
| Column | Type | Key |
|---|---|---|
| shipment_id | INT | PK |
| carrier_id | INT | FK → dim_carriers |
| lane_id | INT | FK → dim_lanes |
| planned_pickup_date | TEXT | |
| actual_pickup_date | TEXT | |
| planned_delivery_date | TEXT | |
| actual_delivery_date | TEXT | |
| qty_ordered | INT | |
| qty_shipped | INT | |
| weight_lbs | REAL | |
| freight_cost | REAL | |
| fuel_surcharge | REAL | |
| accessorial_cost | REAL | |
| dwell_hours_at_origin | REAL | |
| status | TEXT |
Each hint you reveal reduces the XP you can earn. Try the query first.
Use SUM() on each of the three cost columns separately.
Compute total_spend as the sum of all three: freight_cost + fuel_surcharge + accessorial_cost.
No GROUP BY — you want a single aggregate row across the whole table.