https://leetcode.com/problems/consecutive-numbers/
Consecutive Numbers - LeetCode
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
select distinct l1.num as ConsecutiveNums
from logs l1, logs l2, logs l3
where l1.id + 1 = l2.id and l2.id + 1 = l3.id and l1.num = l2.num and l2.num = l3.num
풀이:
from에서 logs를 3번 부른 후, id와 num을 검사하여 출력하면 됩니다.
그리고 num이 중복될 수 있으니 distinct를 해 주어야 합니다.
'Leetcode' 카테고리의 다른 글
[LeetCode] Department Highest Salary [MySQL] (0) | 2022.06.17 |
---|---|
LeetCode 181. Employees Earning More Than Their Managers [MySql] (0) | 2022.06.03 |
LeetCode 178. Rank Scores [MySql] (0) | 2022.06.03 |
LeetCode 1115. Print FooBar Alternately [C++/ promise] (0) | 2022.06.03 |
LeetCode 1114. Print in Order [C++/ atomic] (0) | 2022.06.03 |