- Give the class names and countries of the classes that carried
guns of at least 16-inch bore.
select class, country from classes where bore >= 16;
- List (the names of) all the ships mentioned in the database.
This will probably involve a union.
select name from ships
union
select ship from outcomes;
- Find the names of the ships with a 16-inch bore.
select name
from ships, classes
where ships.class = classes.class
and bore=16;
- Ships sunk in the battle of Denmark Strait. Just the names.
select ship
from outcomes
where battle='Denmark Strait' and result='sunk';
- Ships, with country, number of guns and bore (if known)
sunk in the battle of Denmark Strait. (outer join)
select ship, numguns, bore
from outcomes left join ships on ship=name left join classes on
ships.class = classes.classships.class = classes.class
where battle='Denmark Strait' and result='sunk';
- Ships that violated the treaty of Washington of 1921 (heavier
than 35,000 tons.)
select name from ships natural join classes
where displacement > 35000;
- Ships that "lived to fight another day" -- were damaged in one
battle and later fought in another battle.
Hint: join OB with itself.
select ob1.ship
from ob ob1, ob ob2
where ob1.ship = ob2.ship -- same ship
and ob1.result = 'damaged' -- damaged in one battle
and ob1.date < ob2.date; -- fought in a later battle
Please create a