题解 | #2021年国庆在北京接单3次及以上的司机统计信息

2021年国庆在北京接单3次及以上的司机统计信息

https://www.nowcoder.com/practice/992783fd80f746d49e790d33ee537c19

select 
city,
round(avg(avg_order_num),3) as avg_order_num,
round(avg(avg_income),3) as avg_income
from
(   
    select 
    t1.city as city,
    t2.driver_id,
    round(count(t2.order_id),3) as avg_order_num,
    round(sum(t2.fare),3) as avg_income
    from tb_get_car_record t1
    left join tb_get_car_order t2
    on t1.uid = t2.uid
    and t1.order_id = t2.order_id
    where date(t1.event_time) between '2021-10-01' and '2021-10-07'
    and t1.order_id is not null
    and t1.city = '北京'
    group by t1.city,t2.driver_id
) t
where avg_order_num >= 3
group by city

一直在考虑要不要在where后面加一句and t2.fare is not null

结果就是 接了单 取消了 也算接单了 真就令人无语

全部评论

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务