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

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

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,
    ROUND(SUM(c.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
    o.destination_city,
    t.transport_name
ORDER BY
    o.destination_city,
    t.transport_name;

全部评论

相关推荐

10-21 16:54
门头沟学院 Java
后端转测开第一人:微服务没用 校招都不看微服务的 还有就是后端行情是这样的 找实习纯看运气 秋招更是吃运气和缘分 如果对代码没有极致的追求 可以转测开
应届生简历当中,HR最关...
点赞 评论 收藏
分享
牛油果甜奶昔:别的先不说,牛客还能内推护士?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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