82일차

Suhyeon Lee·2025년 1월 27일

CodeKata

SQL

LeetCode: Human Traffic of Stadium

  • 작성한 쿼리
with cte as (
    select
      *
      , lead(id, 1) over (order by id) as next_id
      , lead(id, 2) over (order by id) as second_next_id
      , lag(id, 1) over (order by id) as last_id
      , lag(id, 2) over (order by id) as second_last_id
    from
      Stadium
    where
      people >= 100
)
select
  distinct id
  , visit_date
  , people
from
  cte
where
  (next_id - id = 1 and id-last_id = 1)
  or (second_next_id - next_id = 1 and next_id - id = 1)
  or (id-last_id = 1 and last_id - second_last_id = 1)
order by
  visit_date
;

최종 프로젝트

  • Tableau
    • 가공한 데이터 원본을 바로 넣으니 너무 처리 속도가 느려서 필요한 부분만 발췌하여 따로 csv 파일을 만들고 파일 간 관계를 지정해 대응

회고

  • 설 연휴에 공부 꼭 하기
    • 주말 이틀 푹 쉬었으니까 나태하게 놀지 말고 일하자!
profile
2 B R 0 2 B

0개의 댓글