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

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

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(*)


全部评论

相关推荐

不愿透露姓名的神秘牛友
05-01 13:13
ecece:这么明目张胆虚报就业率啊
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务