答案
select Num as ConsecutiveNums from (select T.Num, max(T.Count) as Count from (select Num, (case when @pre <> (@pre := Num) then @i := 1 else @i := @i + 1 end) as Count from Logs, (select @i:=0, @pre:=0) init) as T group by Num) as L where L.Count >= 3;
如果不懂,可以參考下下面兩個博客講解再來一步步寫這道題就ok了,加油,相信自己!
https://blog.csdn.net/changrj6/article/details/102508658
https://blog.csdn.net/changrj6/article/details/102483737