-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path601 Human Traffic of Stadium.sql
More file actions
85 lines (83 loc) · 1.12 KB
/
601 Human Traffic of Stadium.sql
File metadata and controls
85 lines (83 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Write your MySQL query statement below
SELECT
*
FROM
stadium s
WHERE
s.id IN (
SELECT
s1.id
FROM
stadium s1,
stadium s2,
stadium s3
WHERE
s2.id = s1.id + 1
AND
s3.id = s2.id + 1
AND
s1.people > 99
AND
s2.people > 99
AND
s3.people > 99
)
OR
s.id IN (
SELECT
s2.id
FROM
stadium s1,
stadium s2,
stadium s3
WHERE
s2.id = s1.id + 1
AND
s3.id = s2.id + 1
AND
s1.people > 99
AND
s2.people > 99
AND
s3.people > 99
)
OR
s.id IN (
SELECT
s3.id
FROM
stadium s1,
stadium s2,
stadium s3
WHERE
s2.id = s1.id + 1
AND
s3.id = s2.id + 1
AND
s1.people > 99
AND
s2.people > 99
AND
s3.people > 99
)
# Write your MySQL query statement below
SELECT DISTINCT
s1.*
FROM
stadium s1,
stadium s2,
stadium s3
WHERE
s1.people > 99
AND
s2.people > 99
AND
s3.people > 99
AND (
(s1.id + 1 = s2.id AND s1.id + 2 = s3.id) # s1, s2, s3
OR
(s2.id + 1 = s1.id AND s2.id + 2 = s3.id) # s2, s1, s3
OR
(s3.id + 1 = s2.id AND s3.id + 2 = s1.id) # s3, s2, s1
)
ORDER BY s1.id;