题解 | 物流公司想要分析快递小哥的薪资构成和绩效情况

物流公司想要分析快递小哥的薪资构成和绩效情况

https://www.nowcoder.com/practice/4be55ba954bf4f928a2d6ff840f23d1b

select
    c.courier_id as courier_id,
    courier_name,
    base_salary + delivery_total - expense_total as total_income
from
    couriers_info as c
    inner join (
        select
            courier_id,
            sum(delivery_fee) as delivery_total
        from
            deliveries_info
        where
            substr(delivery_date, 1, 7) = '2024-07'
        group by
            courier_id
    ) as d on c.courier_id = d.courier_id
    inner join (
        select
            courier_id,
            sum(expense_amount) as expense_total
        from
            expenses_info
        where
            substr(expense_date, 1, 7) = '2024-07'
        group by
            courier_id
    ) as e on c.courier_id = e.courier_id;

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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