bigo的sql题

X市建了一个新的体育馆,每日人流信息记录在三列的信息中,序号(id)/日期(visit_date),人流量(people),写一个查询语句,找出人流量的高峰期。高峰期时,至少连续三行记录中的人流量不少于100.例如表是stadium:

idvisit_datepeople
12019-01-0110
22019-01-02109
32019-01-03150
42019-01-0499
52019-01-05145
62019-01-061455
72019-01-07199
82019-01-08177

对于上面的数据应该得到

SELECT DISTINCT s1.*
FROM studium s1 join studium s2 on s1.id=s2.id-1
join studium s3 on s1.id=s3.id-2
where s1.people>=100
and s2.people>=100
and s3.people>=100
UNION
select DISTINCT s1.*
FROM studium s1 join studium s2 on s1.id=s2.id+1
join studium s3 on s1.id=s3.id+2
where s1.people>=100
and s2.people>=100
and s3.people>=100

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值