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

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

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

1、 时间计算使用 timestampdiff(second,event_time,order_time)/60
才准确
2、注意要求的是工作日

select 
case when hour(event_time) >=7 and hour(event_time) <9 then "早高峰"
 when  hour(event_time) >=9 and hour(event_time) <17 then "工作时间"
 when  hour(event_time) >=17 and hour(event_time) <20 then "晚高峰"
 else "休息时间" end as period,
count(t.order_id) as get_car_num,
round(avg(timestampdiff(second,event_time,order_time)/60),1) as avg_wait_time ,
round(avg(timestampdiff(second,order_time,start_time)/60),1) as avg_dispatch_time
from tb_get_car_order t join tb_get_car_record t1 using(order_id)
where date_format(event_time,"%w") between 1 and 5
group by period
order by get_car_num
全部评论

相关推荐

不愿透露姓名的神秘牛友
07-04 14:23
steelhead:你回的有问题,让人感觉你就是来学习的
点赞 评论 收藏
分享
机械打工仔:我来告诉你原因,是因为sobb有在线简历,有些HR为了快会直接先看在线简历,初步感觉不合适就不会找你要详细的了
投了多少份简历才上岸
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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