Write each of the queries in SQL making sure that duplicates are eliminated: Cla
ID: 3749406 • Letter: W
Question
Write each of the queries in SQL making sure that duplicates are eliminated:
Classes(class, type, country, numGuns, bore, displacement)
Ships (name, class, launched)
Battles (name, date)
Outcomes (ship, battle, result)
a. Give the class name and countries of the classes that carried guns of at least 16-inch bore
b. Find the ships launced prior to 1921
c. Find the ships sunk in the battle of Denmark Strait
d. The treaty of Washington n 1921 prohibited capital ships heavier than 35000 tons. List the ships that violated the Traty of Washington
e. List the name, displacement, and the number of guns f the ships engaged in the battla of Guadalcanal
f. List all of the capital ships mentioned in the database
Explanation / Answer
a. SELECT class,country FROM classes WHERE bore >= 16;
b. SELECT * FROM ships WHERE launched <1921;
c. SELECT ship FROM Outcomes WHERE battle ='Denmark Strait' AND result = 'sunk';
d.SELECT Ships.name FROM ships NATURAL JOIN classes WHERE displacement > 35000;
e.SELECT name,displacement,numguns FROM classes,ships,Outcomes WHERE classes.class = ships.class AND ships.name = outcomes.ship AND battle = 'Guadalcanal'
f. SELECT name as Shipname from ships UNION SELECT ship AS Shipname FROM outcomes;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.