题解 | 物流公司想要分析快递小哥的收入情况
物流公司想要分析快递小哥的收入情况
https://www.nowcoder.com/practice/749ba0168f014c639b516258c0ed6c5d
# 每个人在2024年7月的总收入 按照id排列
with
t1 as(
select
courier_id,
sum(delivery_fee) as dcount
from
deliveries_info
where
delivery_date between '2024-07-01' and '2024-07-31'
group by
courier_id
)
,
t2 as(
select
courier_id,
courier_name,
base_salary+dcount as total_income
from
couriers_info left join t1 using(courier_id)
order by
courier_id
)
select * from t2

