题解 | 各城市最大同时等车人数
各城市最大同时等车人数
https://www.nowcoder.com/practice/f301eccab83c42ab8dab80f28a1eef98
with T as (select city,event_time as t,1 as uv from tb_get_car_record left join tb_get_car_order using(order_id) where year(event_time)=2021 and month(event_time)=10 union all select city,ifnull(start_time,finish_time) as t,-1 as uv from tb_get_car_record left join tb_get_car_order using(order_id) where year(event_time)=2021 and month(event_time)=10) select city ,max(wait_uv)as max_wait_uv from (select *,sum(uv)over(partition by city order by t,uv desc) as wait_uv from T)R group by city order by max_wait_uv,city