Consecutive Numbers
https://leetcode.com/problems/consecutive-numbers/
# 최소 3번이상 연속적으로 나타나는 숫자 찾기
# 순서는 상관없음
SELECT DISTINCT l.num AS ConsecutiveNums -- 중복제거
FROM logs AS l
INNER JOIN logs AS l_next ON l.id + 1 = l_next.id
INNER JOIN logs AS l_next2 ON l.id + 2 = l_next2.id
# three times consecutively
WHERE l.num = l_next.num AND l_next.num = l_next2.num
'기존학습자료 > leetcode, hackerrank' 카테고리의 다른 글
해커랭크 - Top earners (0) | 2023.06.25 |
---|---|
서브쿼리 기초 (0) | 2023.06.24 |
Leetcode 1179 - Reformat Department Table (0) | 2023.06.24 |
Leetcode 183 - Customers Who Never Order (0) | 2023.06.24 |
Leetcode 181 - Employees Earning More Than Their Managers (0) | 2023.06.24 |