题解 | 查询出每个运输方式在不同城市的平均运输时长以及总运输费用
查询出每个运输方式在不同城市的平均运输时长以及总运输费用
https://www.nowcoder.com/practice/673bf7b17e7c4962bcde889980eec872
select
distinct
destination_city,transport_name,
round(avg(timestampdiff(day, order_date,delivery_date))
over(partition by destination_city,transport_id),2)
as average_transport_duration,
sum(total_cost)
over(partition by destination_city,transport_id)
as total_transport_cost
from
order_info
left join cost_data using (order_id)
left join transport_detail using(transport_id)


查看5道真题和解析