self join and order by


  • 0
    C

    I wonder if there is a simple and generic solution using variable to solve problems like more than n consecutive rows.

    select distinct a.id, a.date, a.people
    from stadium a, stadium b, stadium c
      where ((b.id=a.id+1 and c.id=a.id+2) or (b.id=a.id-1 and c.id=a.id-2) or (b.id=a.id+1 and c.id=a.id-1)) and
            (a.people>=100 and b.people>=100 and c.people>=100)
    order by a.id
    

Log in to reply
 

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