SELECT a.Num FROM Logs a JOIN Logs b ON a.Id=b.Id+1 JOIN Logs c ON a.Id=c.Id+2 WHERE a.Num=b.Num AND b.Num=c.Num
This should give the exact same result since there is no duplicate values after join.
I cannot think of any duplicates. After JOIN with those ON conditions, there should be only five row left (111/211/121/212/221). And the WHERE condition will give you the first row which is 111. And since I only SELECT a.Num, it should be just 1.
And I also created the table and ran it some where else and my code works. So I'm confused.
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.