题解 | 饿了么需要分析不同配送员在不同天气条件下的配送效率和用户投诉情况

饿了么需要分析不同配送员在不同天气条件下的配送效率和用户投诉情况

https://www.nowcoder.com/practice/e27ba25e7722478eb86c832fab96fc1a

select 
    t.weather_type,
    round(avg(dr.delivery_time), 2) as average_delivery_time,
    count(*) as delivery_count
from(
    select
        wc.weather_id,
        wc.weather_type,
        dr.staff_id
    from 
        delivery_records dr join weather_conditions wc on dr.weather_id = wc.weather_id
        join delivery_staff ds on dr.staff_id = ds.staff_id
    where
        ds.average_speed > 20
    group by
        wc.weather_id, wc.weather_type, dr.staff_id
    having
        sum(dr.is_complaint) / count(*) < 0.5) t
    left join delivery_records dr on t.weather_id = dr.weather_id and t.staff_id = dr.staff_id
group by
    t.weather_type
order by
    t.weather_type;

全部评论

相关推荐

政委qqq:这道题在算法竞赛里唯一考的就是高精度,但是只能难住C++这类语言,Python直接a+b秒天秒地
点赞 评论 收藏
分享
1jian10:48h没写面评会变成这样
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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