-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSQL Queries.sql
52 lines (45 loc) · 994 Bytes
/
SQL Queries.sql
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
use sports_betting;
SELECT
w.year AS year,
w.month AS month,
w.state AS state,
w.revenue AS revenue,
w.handle AS handle,
w.hold AS hold,
w.taxes AS taxes,
d.population AS population,
d.poverty AS poverty,
d.unemployed AS unemployed,
d.med_income AS med_income,
s.online AS online,
s.in_person AS in_person
FROM wager w
LEFT JOIN demographics d
ON(w.year = d.year and w.state = d.state)
LEFT JOIN status s
ON(s.state = w.state)
UNION
SELECT
d2.year AS year,
w2.month AS month,
d2.state AS state,
w2.revenue AS revenue,
w2.handle AS handle,
w2.hold AS hold,
w2.taxes AS taxes,
d2.population AS population,
d2.poverty AS poverty,
d2.unemployed AS unemployed,
d2.med_income AS med_income,
s2.online AS online,
s2.in_person AS in_person
FROM wager w2
RIGHT JOIN demographics d2
ON(w2.year = d2.year and w2.state = d2.state)
LEFT JOIN status s2
ON(s2.state = d2.state);
SELECT * FROM demographics;
select * from income;
select * from wager;
select * from status;
select * from population;