섭섭의 공부/SQL
[LeetCode] Consecutive Numbers
seobbseob
2021. 12. 24. 09:58
select distinct l1.num as consecutivenums
from logs as l1
left join logs as l2 on l1.id + 1 = l2.id
left join logs as l3 on l1.id + 2 = l3.id
where l1.num = l2.num and l2.num = l3.num
join은 여러 번 사용할 수 있다.