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

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

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

--按照的题目分开去考虑解析:
--每种天气类型下,平均配送速度大于 20 且投诉率(投诉数量 / 配送订单总数量)低于50%的所有配送员的ID
--上面求完符合要求,连接符合人在连接表,求每个天气下的平均速度和平均单数
with tiaojian as (
select 
df.staff_id
from delivery_records ds inner join delivery_staff df 
on ds.staff_id=df.staff_id
inner join weather_conditions ws 
on ws.weather_id=ds.weather_id
group by df.staff_id,ws.weather_id
having avg(delivery_time)>20 and sum(is_complaint=1)/count(record_id)<0.5
)


select 
ws.weather_type,
round(avg(delivery_time),2) as average_delivery_time,
count(ds.record_id) as delivery_count
from  tiaojian t inner join delivery_records ds 
on t.staff_id=ds.staff_id
inner join weather_conditions ws on ws.weather_id=ds.weather_id
group by ws.weather_id
order by ws.weather_type

全部评论

相关推荐

敢逐云霄志:你打招呼语怎么能这么长,hr都没看下去的欲望,简明扼要说重点,就读于某某学校某某专业,26届应届毕业生,学信网可查,先后在某某公司实习过(如有),然后做过什么项目,想找一份什么样的工作,可实习几个月以上,期待您的回复。
点赞 评论 收藏
分享
程序员牛肉:可以说含金量不如王者荣耀省标。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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