题解 | #各城市最大同时等车人数#

各城市最大同时等车人数

https://www.nowcoder.com/practice/f301eccab83c42ab8dab80f28a1eef98

select 
    city 
    ,max(wait_diff) max_wait_uv
from
(
select 
    city
    ,date(dt) day1
    ,dt
    ,sum(diff)over(partition by city,date(dt) order by dt,diff desc) wait_diff
from
(
select 
    city 
    ,event_time dt
    ,1 diff
from tb_get_car_record 
union all 
select 
    city
    ,end_time dt 
    ,-1 diff 
from tb_get_car_record 
where order_id is null 
union all 
select 
    t2.city city 
    ,ifnull(start_time,finish_time) dt
    ,-1 diff
from tb_get_car_order t1
left join tb_get_car_record t2 
on t1.order_id=t2.order_id and t1.uid=t2.uid 
) a0
where date(dt) between '2021-10-01' and '2021-10-31'
) a1
group by 1 
order by 2,1

全部评论

相关推荐

10-14 23:01
已编辑
中国地质大学(武汉) Java
CUG芝士圈:虽然是网上的项目,但最好还是包装一下,然后现在大部分公司都在忙校招,十月底、十一月初会好找一些。最后,boss才沟通100家,别焦虑,我去年暑假找第一段实习的时候沟通了500➕才有面试,校友加油
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务