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

各城市最大同时等车人数

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

全部评论

相关推荐

哈哈哈哈哈哈哈哈哈哈这个世界太美好了
凉风落木楚山秋:毕业出路老师不管,你盖个章他好交差就完事了,等你盖完毕业了就不关他事情了
点赞 评论 收藏
分享
人力小鱼姐:实习经历没有什么含金量,咖啡店员迎宾这种就别写了,其他两段包装一下 想找人力相关的话,总结一下个人优势,结合校园经历里有相关性的部分,加一段自我评价
点赞 评论 收藏
分享
06-17 00:26
门头沟学院 Java
程序员小白条:建议换下项目,智能 AI 旅游推荐平台:https://github.com/luoye6/vue3_tourism_frontend 智能 AI 校园二手交易平台:https://github.com/luoye6/vue3_trade_frontend GPT 智能图书馆:https://github.com/luoye6/Vue_BookManageSystem 选项目要选自己能掌握的,然后最好能自己拓展的,分布式这种尽量别去写,不然你只能背八股文了,另外实习的话要多投,尤其是学历不利的情况下,多找几段实习,最好公司title大一点的
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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