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

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

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

#思路:
#①有订单就计入叫车量,所以要用叫车表左联接单表,保证叫车数据不丢失;
#②调度时间是用上车时间-接单时间,上车时间可能是null,但不影响计算平均值,因为avg()会忽略null值;
#③叫车表在左联之前,要将每日时间做分类。

select a, 
count(event_time) b, 
round(avg(timestampdiff(second,event_time,end_time))/60,1),
round(avg(timestampdiff(second,order_time,start_time))/60,1)
from
(select event_time, end_time, order_id,
case when hour(event_time) between 7 and 8 then '早高峰'
when hour(event_time) between 9 and 16 then '工作时间'
when hour(event_time) between 17 and 19 then '晚高峰'
else '休息时间' end as a
from tb_get_car_record) as tb1
left join 
tb_get_car_order
using(order_id)
where dayofweek(event_time) between 2 and 6
group by a
order by b

全部评论

相关推荐

09-29 16:59
已编辑
门头沟学院 Java
牛客96609213...:疯狂背刺,之前还明确设置截止日期,还有笔试,现在一帮人卡在复筛,他反而一边开启扩招,还给扩招的免笔试,真服了,你好歹先把复筛中的给处理了再说
投递大疆等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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