601. 体育馆的人流量

601. 体育馆的人流量

暴力搜索条件

一开始不知道怎么去重,然后看了一眼评论区就行白了,直接 select s1.* 就可以对全表的数据进行去重

 

# Write your MySQL query statement below
select
    distinct s1.*
from
    stadium s1, stadium s2, stadium s3
where
    (s1.id + 1 = s2.id and s2.id + 1 = s3.id and s1.people >= 100 and s2.people >= 100 and s3.people >= 100)
or
    (s1.id - 1 = s2.id and s2.id - 1 = s3.id and s1.people >= 100 and s2.people >= 100 and s3.people >= 100)
or 
    (s1.id - 1 = s2.id and s1.id + 1 = s3.id and s1.people >= 100 and s2.people >= 100 and s3.people >= 100)
order by
    visit_date
asc
;

 

 

posted @ 2020-03-27 11:45  Let_Life_Stop  阅读(143)  评论(0编辑  收藏  举报