Ai
1 Star 0 Fork 0

逸扬/leetcode-hub-mysql

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lc-0601.test 1.47 KB
一键复制 编辑 原始数据 按行查看 历史
逸扬 提交于 2022-05-01 21:49 +08:00 . fix lc-0577.test lc-0578.test
# 601. 体育馆的人流量
# https://leetcode-cn.com/problems/human-traffic-of-stadium/
# SQL架构
Create table If Not Exists Stadium (id int, visit_date DATE NULL, people int);
Truncate table Stadium;
insert into Stadium (id, visit_date, people) values ('1', '2017-01-01', '10');
insert into Stadium (id, visit_date, people) values ('2', '2017-01-02', '109');
insert into Stadium (id, visit_date, people) values ('3', '2017-01-03', '150');
insert into Stadium (id, visit_date, people) values ('4', '2017-01-04', '99');
insert into Stadium (id, visit_date, people) values ('5', '2017-01-05', '145');
insert into Stadium (id, visit_date, people) values ('6', '2017-01-06', '1455');
insert into Stadium (id, visit_date, people) values ('7', '2017-01-07', '199');
insert into Stadium (id, visit_date, people) values ('8', '2017-01-09', '188');
# Write your MySQL query statement below
select
distinct s1.id,
s1.visit_date,
s1.people
from
Stadium s1,
Stadium s2,
Stadium s3
where
s1.people >= 100
and s2.people >= 100
and s3.people >= 100
and (
(
s1.id - s2.id = 1
and s1.id - s3.id = 2
and s2.id - s3.id = 1
)
or (
s2.id - s1.id = 1
and s2.id - s3.id = 2
and s1.id - s3.id = 1
)
or (
s3.id - s2.id = 1
and s2.id - s1.id = 1
and s3.id - s1.id = 2
)
)
order by
s1.id;
# clean-up
drop table Stadium;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/gdut_yy/leetcode-hub-mysql.git
git@gitee.com:gdut_yy/leetcode-hub-mysql.git
gdut_yy
leetcode-hub-mysql
leetcode-hub-mysql
master

搜索帮助