티스토리 뷰

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

'프로그래밍연습 > SQL' 카테고리의 다른 글

[SQL]friend-requests-ii-who-has-the-most-friends  (0) 2023.08.20
[SQL]game-play-analysis-iv  (0) 2023.08.19
[SQL]trips-and-users  (0) 2023.08.18
[SQL]employees-earning-more-than-their-managers  (0) 2023.08.17
[SQL]consecutive-numbers  (0) 2023.08.17
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
글 보관함