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

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

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

select period,count(*) get_car_num,
round(sum(timestampdiff(second,event_time,end_time)/60)/count(*),1)avg_wait_time,
round(sum(timestampdiff(second,order_time,ifnull(start_time,order_time))/60)/count(start_time),1)avg_dispatch_time
from
(
select distinct cr.order_id,cr.event_time,cr.end_time,co.order_time,co.start_time,
case 
when date_format(cr.event_time,"%H%i%S")>='070000' and date_format(cr.event_time,"%H%i%S")<'090000' then '早高峰'
when date_format(cr.event_time,"%H%i%S")>='090000' and date_format(cr.event_time,"%H%i%S")<'170000' then '工作时间'
when date_format(cr.event_time,"%H%i%S")>='170000' and date_format(cr.event_time,"%H%i%S")<'200000' then '晚高峰'
else '休息时间'
end period
from  tb_get_car_record cr join tb_get_car_order co using(order_id)
where DAYOFWEEK(cr.event_time) BETWEEN 2 AND 6
)t1
group by period
order by get_car_num,avg_dispatch_time

全部评论

相关推荐

05-12 13:14
已编辑
中山大学 算法工程师
点赞 评论 收藏
分享
03-24 16:56
已编辑
肇庆学院 后端
一天代码十万三:你看看人家进大厂的简历就知道了,你这个学历得acm+大厂实习+熟悉底层+运气很好 才有可能进某个大厂,因为大部分是直接卡学历的
投递快手等公司10个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务