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

各城市最大同时等车人数

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

全部评论

相关推荐

烤点老白薯:可以 除了名字都偷了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
正在热议
更多
牛客网
牛客企业服务