美文网首页
180. Consecutive Numbers

180. Consecutive Numbers

作者: wenmingxing | 来源:发表于2018-07-23 10:40 被阅读33次
    题目链接:

    180. Consecutive Numbers

    解析:

    这道题比较简单,就是将表应用三次,直接使用WHERE限定即可,值的注意的是需要使用DISTINCT来进行去重。

    题解:
    # Write your MySQL query statement below
    SELECT DISTINCT L1.Num AS ConsecutiveNums FROM Logs L1, Logs L2, Logs L3 
    WHERE L1.Id+1 = L2.Id AND L2.Id+1 = L3.Id AND L1.Num = L2.Num AND L2.Num = L3.Num;
    

    相关文章

      网友评论

          本文标题:180. Consecutive Numbers

          本文链接:https://www.haomeiwen.com/subject/hsmdmftx.html