题解 | 物流公司想要分析快递小哥的收入情况
物流公司想要分析快递小哥的收入情况
https://www.nowcoder.com/practice/749ba0168f014c639b516258c0ed6c5d
select
c.courier_id as courier_id,
courier_name,
base_salary + total_fee as total_income
from
couriers_info as c
inner join (
select
courier_id,
sum(delivery_fee) as total_fee
from
deliveries_info
where
substr(delivery_date, 1, 7) = '2024-07'
group by
courier_id
) as f on c.courier_id = f.courier_id
order by
courier_id;