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

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

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

select t1.period
,count(*) as get_car_num
,round(avg(t1.wait_time),1)
,round(avg(t1.dispatch_time),1) 
from (
select (case when hour(r1.event_time)>=7 and hour(r1.event_time)<9 then '早高峰' 
      when hour(r1.event_time)>=9 and hour(r1.event_time)<17 then '工作时间' 
      when hour(r1.event_time)>=17 and hour(r1.event_time)<20 then '晚高峰' 
      when (hour(r1.event_time)>=20 and hour(r1.event_time)<24) or  
       (hour(r1.event_time)>=0 and hour(r1.event_time)<7 ) then '休息时间' end ) as period, 
       timestampdiff(second,o1.order_time,o1.start_time)/60 as dispatch_time,
       timestampdiff(second,r1.event_time,o1.order_time)/60 as wait_time 
       from tb_get_car_order as o1 left join tb_get_car_record as r1 
       on o1.order_id = r1.order_id 
#        date_format(o1.event_time,'%W') not in ('Saturday','Sunday')
where weekday(r1.event_time) between 0 and 4 
) t1  group by t1.period order by count(*)


全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 11:55
点赞 评论 收藏
分享
06-17 21:57
门头沟学院 Java
白友:噗嗤,我发现有些人事就爱发这些,明明已读不回就行了,就是要恶心人
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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