Leetcode 601. 体育馆的人流量(lag 和head 函数)

2021-04-20 11:00:00 浏览数 (1)

代码语言:javascript复制
select id,visit_date,people
    from(
        select *,
        lag(people,1) over(order by id)l1,
        lag(people,2)over(order by id) l2,
        lead(people,1) over(order by id)l3,
        lead(people,2) over(order by id)l4 
        from stadium
    )A
    where (l1>=100 and l2>=100 and people>=100)
        or(l1>=100 and people>=100 and l3>=100)
        or(people>=100 and l3>=100 and l4>=100)

0 人点赞