select destination_city, transport_name, average_transport_duration, total_transport_cost
from (
select destination_city, transport_id,
round(avg(timestampdiff(hour, order_date, delivery_date)/24), 2) as average_transport_duration,
sum(total_cost) as total_transport_cost
from order_info a join cost_data b on a.order_id=b.order_id
group by destination_city, transport_id
) temp join transport_detail c on temp.transport_id=c.transport_id
order by destination_city, transport_name

京公网安备 11010502036488号