题解 | 查询出每个运输方式在不同城市的平均运输时长以及总运输费用

查询出每个运输方式在不同城市的平均运输时长以及总运输费用

https://www.nowcoder.com/practice/673bf7b17e7c4962bcde889980eec872

select
    destination_city,
    transport_name,
    round(
        avg(timestampdiff(day, order_date, delivery_date)),
        2
    ) as average_transport_duration,
    round(sum(total_cost),2) as total_transport_cost
from
    transport_detail as t
    inner join order_info as o on t.transport_id = o.transport_id
    inner join cost_data as c on o.order_id = c.order_id
group by
    destination_city,
    transport_name
order by
    destination_city asc,
    transport_name asc;

全部评论

相关推荐

2025-12-13 14:51
已编辑
井冈山大学 算法工程师
龙虾x:算法比你强的没有你美,比你美的…..算了已经没有比你美的了
工作两年想退休了
点赞 评论 收藏
分享
后端测试双料特工:这能忍住不骂?
找实习记录
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务