投递记录2

8.19 科尔尼-商业分析师-投递
8.20 搜狐畅游-财务-投递
8.20 三未信安- HR-投递
#非技术投递记录#
全部评论

相关推荐

SQL178 工作日各时段叫车量、等待接单时间和调度时间叫车量:因为每一次打车记录都赋予了时段,故count(period)即为某一时段的叫车量等待时间:结束打车时间-打车时间。因为有可能出现打车过程中取消订单的情况,此时order_id为null,使用if()将其筛掉即可。调度时间:即司机过来接你上车所用的时间。start_time-order_time可以通过case来给period字段分配多个值,是否工作日可以用dayofweek判断:1为周日,2为周一以此类推;time()函数将日期格式化为时分秒的类型,使用加减运算则返回秒数,再除以60就可以转换为分钟;with t1 as(select    case    when time(event_time)>='07:00:00' and time(event_time)<'09:00:00' then '早高峰'    when time(event_time)>='09:00:00' and time(event_time)<'17:00:00' then '工作时间'    when time(event_time)>='17:00:00' and time(event_time)<'20:00:00' then '晚高峰'    else '休息时间'    end period    ,if(tb_get_car_record.order_id is null,null,timestampdiff(second,event_time,end_time)) wait_time    ,timestampdiff(second,order_time,start_time) as dispatch_timefrom    tb_get_car_record left join tb_get_car_order    on tb_get_car_record.order_id=tb_get_car_order.order_idwhere    dayofweek(event_time) >1    and     dayofweek(event_time) <7)select     period    ,count(period) as get_car_num    ,round(avg(wait_time)/60,1) as avg_wait_time    ,round(avg(dispatch_time)/60,1) as avg_dispatch_timefrom     t1group by    periodorder by    get_car_num asc
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务