A simple solution using HAVING


  • 0
    A
    SELECT DISTINCT e.*
    FROM (   
        SELECT a.id
        FROM stadium a
        JOIN stadium b ON b.id - a.id BETWEEN 1 AND 2 
        WHERE a.people >= 100 and b.people >= 100
        GROUP BY a.id HAVING count(*) = 2 
    ) d
    JOIN stadium e ON e.id - d.id BETWEEN 0 AND 2
    

Log in to reply
 

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