A solution with union, join and where


  • 1
    D
    select s.* from stadium s inner join
    (select distinct s1.id as id from stadium s1,stadium s2, stadium s3
    where  s1.id+1=s2.id and s2.id+1=s3.id and s1.people > 99 and s2.people > 99 and s3.people > 99 
    union 
    select distinct s2.id as id from stadium s1,stadium s2, stadium s3
    where  s1.id+1=s2.id and s2.id+1=s3.id and s1.people > 99 and s2.people > 99 and s3.people > 99 
    union
    select distinct s3.id as id from stadium s1,stadium s2, stadium s3
    where  s1.id+1=s2.id and s2.id+1=s3.id and s1.people > 99 and s2.people > 99 and s3.people > 99 ) a
    on a.id=s.id; 
    

Log in to reply
 

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