-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path42-46_48.sql
51 lines (45 loc) · 1.18 KB
/
42-46_48.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
51
--42
SELECT oc.ship, oc.battle FROM Outcomes oc
WHERE result = 'sunk'
--43
SELECT bt.name FROM Battles bt
WHERE YEAR(bt.date) NOT IN
(SELECT sh.launched FROM Ships sh
JOIN Battles bt ON sh.launched = YEAR(bt.date))
--44
SELECT ship FROM
(SELECT name ship FROM Ships
UNION
SELECT ship FROM Outcomes) t1
WHERE ship LIKE 'r%' OR ship LIKE 'R%'
--45
SELECT ship FROM
(SELECT name ship FROM Ships
UNION
SELECT ship FROM Outcomes) t1
WHERE ship LIKE '% % %'
--46
select sh.name, cl.displacement, cl.numguns from outcomes ou
join ships sh on sh.name = ou.ship
join classes cl on sh.class = cl.class
where battle = 'Guadalcanal'
UNION
select ou.ship, cl.displacement, cl.numguns from outcomes ou
left join classes cl on cl.class = ou.ship
where ou.ship not in
(select name from ships)
and battle = 'Guadalcanal'
--47
--Nope. Too much for me
--48
select cl.class from classes cl
join ships sh on sh.class = cl.class
join outcomes ou on ou.ship = sh.name and result = 'sunk'
union
(select cl.class from classes cl
join outcomes ou on cl.class = ou.ship and result = 'sunk'
except
select cl.class from classes cl
join outcomes ou on cl.class = ou.ship and result = 'sunk'
where ou.ship in (select name from ships)
)