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

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

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

with t1 as(
    select tb2.order_id,event_time,order_time,start_time,finish_time
    from tb_get_car_order tb2
    left join  tb_get_car_record tb1
    on tb1.order_id=tb2.order_id
    WHERE DAYOFWEEK(date(event_time)) BETWEEN 2 AND 6
),
t2 as(select (case when date_format(event_time,'%H:%i:%s')>='09:00:00' and date_format(event_time,'%H:%i:%s')<'17:00:00' then '工作时间'
when (date_format(event_time,'%H:%i:%s')>='20:00:00' and date_format(event_time,'%H:%i:%s')<'23:59:59') or (date_format(event_time,'%H:%i:%s')>='00:00:00' and date_format(event_time,'%H:%i:%s')<'07:00:00')  then '休息时间'
when date_format(event_time,'%H:%i:%s')>='17:00:00' and date_format(event_time,'%H:%i:%s')<'20:00:00'  then '晚高峰'
when date_format(event_time,'%H:%i:%s')>='07:00:00' and date_format(event_time,'%H:%i:%s')<'09:00:00'  then '早高峰' end) as period,order_id,event_time,order_time,start_time,finish_time
from t1)
select period ,count(period)  get_car_num,round((sum(timestampdiff(second,event_time,order_time))/count(order_time))/60,1)   avg_wait_time,round((sum(timestampdiff(second,order_time,start_time))/count(start_time))/60,1) avg_dispatch_time
from t2
group by period
order by get_car_num

全部评论

相关推荐

大佬们,在大厂实习的都是几百一天???
哈尔滨的移动城堡_:那几个有名的大厂都是300-400,小厂有更高的
点赞 评论 收藏
分享
mama3925:建议专业技能里测试移到最上面,加粗。然后适当加入些自动化测试工具。第二个项目,第三条亮点最后错别字。然后佬如果对自己很自信的话,可以项目放前面,然后项目里可以编造点测试经历,写在写在项目亮点的前两行。最后可加个自我评价,放个博客或者仓库链接
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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