Coding Test

Leetcode - 601. Human Traffic of Stadium

Indo Yoon

문제

Loading...
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.

정답

CREATE VIEW 가 안돼서 찾아보니 다행히 WITH AS 로 뷰를 만들 수 있었다.

WITH temp AS (
select *, id - ROW_NUMBER() OVER(ORDER BY id) AS gap
FROM Stadium
WHERE people >= 100
)
SELECT id, visit_date, people
FROM temp
WHERE gap IN (SELECT gap FROM temp GROUP BY gap HAVING COUNT(*) >= 3)