题解 | 查询出每个运输方式在不同城市的平均运输时长以及总运输费用
查询出每个运输方式在不同城市的平均运输时长以及总运输费用
https://www.nowcoder.com/practice/673bf7b17e7c4962bcde889980eec872
select o.destination_city,t.transport_name,round(avg(timestampdiff(DAY,o.order_date,o.delivery_date)),2) as average_transport_duration,sum(c.total_cost) as total_transport_cost from order_info as o left join transport_detail as t on o.transport_id = t.transport_id left join cost_data as c on o.order_id = c.order_id group by o.destination_city,t.transport_name order by o.destination_city,t.transport_name ;
我勒个 这个题这不是挺短的吗 咋看答案大家写的老长了 需要注意的依旧是时间计算timestampdiff(DAY,结束时间,开始时间)
