Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
31 |
Tags
- 당신의 인생이 왜 힘들지 않아야 한다고 생각하십니까
- HackerRank
- forecast
- leetcode
- 코딩테스트
- eda
- ProfileReport
- 딥러닝
- 신경쓰기의 기술
- tensorflow
- TensorFlowGPU
- 파이썬
- Gaimification
- Inventory Optimization
- SQL
- MS SQL Server
- 프로그래머스
- 코딩테스트연습
- ABC Analysis
- SKU Consolidation
- Labor Management System
- pandas profiling
- ModelCheckPoint
- 피그마인디언
- oracle
- kaggle
- 데이터분석
- MySQL
- Product Demand
- 웨어하우스 보관 최적화
Archives
- Today
- Total
오늘도 배운다
601. Human Traffic of Stadium / LeetCode, SQL, MS SQL 본문
코딩테스트연습(SQL)
601. Human Traffic of Stadium / LeetCode, SQL, MS SQL
LearnerToRunner 2023. 3. 18. 17:48문제
source: LeetCode
Write an SQL query to display the records with three or more rows with consecutive id's, and the number of people is greater than or equal to 100 for each.
Return the result table ordered by visit_date in ascending order.
제출답안(MySQL)
WITH std AS (
SELECT
id, visit_date, people, id - ROW_NUMBER() OVER(ORDER BY id) AS row_num
FROM stadium
WHERE people >= 100
),
std_cons AS (
SELECT row_num
FROM std
GROUP BY row_num
HAVING COUNT(id) >= 3
)
SELECT id, visit_date, people
FROM std
WHERE row_num IN (SELECT row_num FROM std_cons)
문제 바로가기(MySQL)
728x90
'코딩테스트연습(SQL)' 카테고리의 다른 글
조회수가 가장 많은 중고거래 게시판의 첨부파일 조회하기 / 프로그래머스, SQL, MySQL (0) | 2023.03.20 |
---|---|
185. Department Top Three Salaries / LeetCode, SQL, MS SQL Server (0) | 2023.03.19 |
262. Trips and Users / LeetCode, SQL, MySQL (0) | 2023.03.14 |
607. Sales Person / LeetCode, SQL, MySQL (0) | 2023.03.13 |
1527. Patients With a Condition / LeetCode, SQL, MySQL (0) | 2023.03.11 |
Comments