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

各城市最大同时等车人数

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

-- 各个城市,2021年10月期间,单日最大同时等车人数
with t1 as (select city,a.uid,event_time,
case when b.order_time is null then end_time 
when a.end_time = b.order_time and b.start_time is not null then b.start_time 
when a.end_time = b.order_time and b.start_time is null then b.finish_time else null end over_time
from tb_get_car_record a 
left join tb_get_car_order b
on a.uid = b.uid
and a.order_id = b.order_id
where substr(event_time,1,7) = '2021-10'
),
t2 as (select event_time dt from t1
union all
select over_time dt from t1)

select city,max(wait_uv) max_wait_uv from (select city,dt,count(distinct case when follow_num = 1 then uid else null end) wait_uv
from (select dt,city,uid,
case when t1.event_time > dt then 0 when t1.event_time <= dt and t1.over_time >= dt then 1 when t1.over_time < dt then 0 end follow_num
from t2 join t1) u 
group by city,dt) v 
group by city
order by max_wait_uv,city ASC

全部评论

相关推荐

10-27 02:29
已编辑
门头沟学院 嵌入式工程师
牛客72783561...:简历不是这么写的,你这两个项目只说了用到了什么技术,却没说取得了什么成果,在我看来这就是你自己做的一个demo,没有价值。你为什么不写你电赛国二的那个项目?
点赞 评论 收藏
分享
程序员牛肉:你这简历有啥值得拷打的?在牛客你这种简历一抓一大把,也就是个人信息不一样而已。 关键要去找亮点,亮点啊,整个简历都跟流水线生产出来的一样。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务