题解 | #工作日各时段叫车量、等待接单时间和调度时间#

工作日各时段叫车量、等待接单时间和调度时间

https://www.nowcoder.com/practice/34f88f6d6dc549f6bc732eb2128aa338

-- 统计周一到周五各时段的叫车量、平均等待接单时间和平均调度时间。全部以event_time-开始打车时间为时段划分依据,平均等待接单时间和平均调度时间均保留1位小数,平均调度时间仅计算完成了的订单,结果按叫车量升序排序
with t1 as (select a.uid,
case when time(event_time) >= '07:00:00' and time(event_time) < '09:00:00' then '早高峰' when time(event_time) >= '09:00:00' and time(event_time) < '17:00:00' then '工作时间' when time(event_time) >= '17:00:00' and time(event_time) < '20:00:00' then '晚高峰' else '休息时间' end period,start_time,order_time,finish_time,
timestampdiff(second,event_time,order_time) wait_time,
timestampdiff(second,order_time,start_time) dispatch_time
from tb_get_car_record a 
left join tb_get_car_order b
on a.order_id = b.order_id and a.uid = b.uid
where weekday(a.event_time) between 0 and 4
)
select period,count(uid) get_car_num,round(avg(wait_time)/60,1) avg_wait_time,round(avg(dispatch_time)/60,1) avg_dispatch_time from t1 

group by period
order by get_car_num ASC

全部评论

相关推荐

Southyeung:我说一下我的看法(有冒犯实属抱歉):(1)简历不太美观,给我一种看都不想看的感觉,感觉字体还是排版问题;(2)numpy就一个基础包,机器学习算法是什么鬼?我感觉你把svm那些写上去都要好一点。(2)课程不要写,没人看,换成获奖经历;(3)项目太少了,至少2-3个,是在不行把网上学习的也写上去。
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
06-24 14:18
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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