leetcode 601体育馆的人流量

leetcode 601体育馆的人流量_第1张图片
leetcode 601体育馆的人流量_第2张图片

select id, visit_date, people
from(
    select a.*, @j:=if(@num2>=100 and people>=100, @j, @j+1) as orders, @num2:=people as peo
    from stadium as a, (select @num2:=0, @j:=0) as b
) as a
where a.orders in (
select b.orders
from(
    select a.*, @i:=if(@num1>=100 and people>=100, @i, @i+1) as orders, @num1:=people as peo
    from stadium as a, (select @num1:=0, @i:=0) as b
) as b
group by b.orders
having count(b.orders)>=3
)

你可能感兴趣的:(leetcode,sql)