180. 连续出现的数字
【题目】编写一个 SQL 查询,查找所有至少连续出现三次的数字。
返回的结果表中的数据可以按 任意顺序 排列。
题解:作两次左连接
# Write your MySQL query statement below SELECT T1.Num AS ConsecutiveNums FROM Logs T1 LEFT JOIN Logs T2 ON T1.Id = T2.Id-1 LEFT JOIN Logs T3 ON T2.Id = T3.Id-1 WHERE T1.Num = T2.Num AND T2.Num = T3.Num GROUP BY 1 ;