프로그래밍연습/SQL
[SQL]human-traffic-of-stadium
Q_jihe
2023. 8. 18. 14:45
https://leetcode.com/problems/human-traffic-of-stadium
LeetCode - The World's Leading Online Programming Learning Platform
Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview.
leetcode.com
with base as (
select
distinct id, visit_date, people
, id - row_number() over (order by id) as rn
from Stadium
where people >= 100
)
, base2 as (
select
rn, count(distinct id) cnt
from base
group by 1
)
select
distinct id, visit_date, people
from base
where rn in (select distinct rn from base2 where cnt >= 3)
order by 2