Skip to content

Latest commit

 

History

History
28 lines (20 loc) · 466 Bytes

180.md

File metadata and controls

28 lines (20 loc) · 466 Bytes

Consecutive Numbers

Description

link


Solution

See Code


Code

# Write your MySQL query statement below
select DISTINCT num  AS "ConsecutiveNums" FROM
(select num,
	case 
		when @record = num then @count:=@count+1
		when @record <> @record:=num then @count:=1 end as n
    from 
	    Logs ,(select @count:=0,@record:=(SELECT num from Logs limit 0,1)) r
) a
where a.n>=3