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

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

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

select 
    period,
    count(period) as get_car_num,
    round(avg(wait_time)/60,1) avg_wait_time,
    round(avg(dispatch_time)/60,1) avg_dispatch_time
from (select (case 
    when hour(a.event_time)<7 or hour(a.event_time)>= 20 then '休息时间' 
    when hour(a.event_time)<9 then '早高峰'
    when  hour(a.event_time)<17 then '工作时间'
    when hour(a.event_time)<20 then '晚高峰' end) period,
    if(a.order_id is null, null, timestampdiff(second, a.event_time, a.end_time))  wait_time	,
     if(b.start_time is null, null, timestampdiff(second, b.order_time, b.start_time)) dispatch_time	
from tb_get_car_record a left join tb_get_car_order b
on a.order_id = b.order_id where dayofweek(event_time) between 2 and 6) t group by period order by get_car_num

全部评论

相关推荐

11-26 22:34
已编辑
重庆邮电大学 Java
快手 客户端开发 (n+5)k*16 公积金12
牛客895077908号:佬 什么双非硕啊
点赞 评论 收藏
分享
挣K存W养DOG:他真的很中意你,为什么不回他
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务