I use variable to do it


  • 1
    L
    SELECT 
      * 
    FROM
      stadium 
    WHERE INSTR(
        (SELECT CONCAT(',',GROUP_CONCAT(tmpaa.ids),',') AS ids FROM (SELECT 
          GROUP_CONCAT(id) AS ids
        FROM
          (SELECT 
            id,
            CASE
              WHEN (
                (@prevone := people) < 100 
                OR (@prevone >= 100 
                  AND @prevtwo < 100)
              ) 
              THEN @group := @group + 1 
              ELSE @group := @group 
            END AS groupno,
            (@prevtwo := people) AS bb 
          FROM
            stadium,
            (SELECT 
              @group := 0,
              @prevone := - 1,
              @prevtwo := - 1) init) AS tmp 
        GROUP BY tmp.groupno 
        HAVING COUNT(1) >= 3 ) AS tmpaa),
        CONCAT(',', id, ',')
      ) > 0
    

Log in to reply
 

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