Leetcode 601. 体育馆的人流量

体育馆:https://leetcode-cn.com/problems/human-traffic-of-stadium/

601.png

with tmp as(
select case when @pre+1=b.id then @r else @r:=@r+1 end id1,b.id,b.visit_date,b.people,@pre:=b.id 
from (select @r:=0,@pre:=0) as init,(select * from Stadium where people>=100)b
)

select b.id,b.visit_date,b.people
from (
select id1 from tmp group by id1 having count(*)>=3
)a left join tmp b on a.id1=b.id1 
order by b.visit_date 
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容