I ran this in my local database(DB2) and it worked. But failed by the last test case........


  • 0
    Z

    select a.Num from ( select l1.Id,l1.Num,l1.Id-count(*) as Cut from Logs l1,Logs l2 where l1.Num=l2.Num and l2.Id<=l1.Id group by l1.Id,l1.Num ) a group by a.Num,a.Cut having count(*)>=3


  • 0
    Z

    I know where is wrong.I need add 'distinct ' to the a.Num.

    select distinct(a.Num) from ( select l1.Id,l1.Num,l1.Id-count(*) as Cut from Logs l1,Logs l2 where l1.Num=l2.Num and l2.Id<=l1.Id group by l1.Id,l1.Num ) a group by a.Num,a.Cut having count(*)>=3

  • 0

    I also add 'distinct' and AC.But why?


  • 0

    Oops! I confuse with the expected output and my output! wtf.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.