Consecutive Numbers

表内自连接,注意是连续的,是内连接
https://leetcode.com/problems/consecutive-numbers/

SELECT DISTINCT l1.Num from Logs l1
INNER JOIN Logs l2
INNER JOIN Logs l3
ON l2.Id=l1.Id+1 AND l1.Num=l2.Num
AND l3.Id=l2.Id+1 AND l2.Num=l3.Num

你可能感兴趣的:(Consecutive Numbers)