180. Consecutive Numbers(SQL)
# Medium
Solution 1:
Solution 2:
# Write your MySQL query statement below
select distinct l1.Num ConsecutiveNums from Logs l1
join Logs l2 on l1.Id = l2.Id-1
join Logs l3 on l1.Id = l3.Id-2
where l1.Num = l2.Num and l2.Num = l3.Num;
# 或者另一种方法
select distinct l1.Num ConsecutiveNums
from Logs l1, Logs l2, Logs l3
where l1.Id = l2.Id-1 and l2.Id = l3.Id-1
and l1.Num = l2.Num and l2.Num = l3.Num;Last updated