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

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

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

select
    a.courier_id,
    courier_name,
    round(
        avg(base_salary) + sum(delivery_fee) / count(distinct c.expense_id) - sum(expense_amount) / count(distinct b.delivery_id),
        2
    ) total_income
from
    couriers_info a
    left join deliveries_info b on a.courier_id = b.courier_id
    left join expenses_info c on a.courier_id = c.courier_id
where
    date_format(delivery_date, '%Y-%m') = '2024-07'
    and date_format(expense_date, '%Y-%m') = '2024-07'
group by
    1,
    2
order by
    1

全部评论

相关推荐

12-11 14:24
门头沟学院 Java
牛客35720396...:不要用boss,全是骗
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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