[LeetCode-SQL]180. 连续出现的数字(SQL)where + distinct
1. 题目
2. 读题(需要重点注意的东西)
思路(暴力):
找出相同的三张Logs表中id连续且相等的值,去重后别名即可。
3. 解法
---------------------------------------------------解法---------------------------------------------------
# Write your MySQL query statement below
select distinct l1.num as 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;
可能存在的问题: