Logistics & Transportation Analytics · Mission 10 of 30Easy

Average freight cost per mode

JOIN fact to dim and GROUP BY a dim attribute to compute an average metric

The Brief

Priya KapoorFreight Finance Leadlogistics-ops

I need average total cost per shipment broken out by freight mode. Join `fact_shipments` to `dim_carriers`, compute avg of (freight_cost + fuel_surcharge + accessorial_cost) as `avg_total_cost`, group by `mode`, round to 2 decimals. Sort by avg_total_cost descending.

You'll practice

GROUP BYJOINORDER BY

Tables & columns available

fact_shipmentsfact15 columns
ColumnTypeKey
shipment_idINTPK
carrier_idINTFK → dim_carriers
lane_idINTFK → dim_lanes
planned_pickup_dateTEXT
actual_pickup_dateTEXT
planned_delivery_dateTEXT
actual_delivery_dateTEXT
qty_orderedINT
qty_shippedINT
weight_lbsREAL
freight_costREAL
fuel_surchargeREAL
accessorial_costREAL
dwell_hours_at_originREAL
statusTEXT
dim_carriersdim6 columns
ColumnTypeKey
carrier_idINTPK
carrier_nameTEXT
scacTEXT
modeTEXT
on_time_target_pctREAL
hq_stateTEXT

Hints (3)

Each hint you reveal reduces the XP you can earn. Try the query first.

Hint 1

Join fact_shipments to dim_carriers on carrier_id to get the mode column.

Hint 2

Total cost per shipment = freight_cost + fuel_surcharge + accessorial_cost. Wrap in AVG() and ROUND().

Hint 3

GROUP BY c.mode to get one row per freight mode (TL, LTL, PARCEL).