Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

shi 4. 20 points (10) Still considering the World War I database. Assume someone

ID: 3706728 • Letter: S

Question

shi 4. 20 points (10) Still considering the World War I database. Assume someone wants t date it was launched and when it was sunk What is the problem with the following query? o write a query that returns for each ship the SELECT S.name, S.launched, B.date FROM Battles B, Ships S WHERE S.namef(SELECT ship FROM Outcomes WHERE results-'sunk') AND B.namet (SELECT battle FROM Outcomes WHERE results-'sunk'); SELEC?". Ships name, shps.lar che ok, Battle , date -s WtER ship-Rona. .(SE?? oIhe Ships.narc uen:wes. nane = C SEGL . battletnom arts es WHERE ves-ts (10) write the corres It is t.'bidek, ? ) u?

Explanation / Answer

Below is the query to return ship sunk details. Please run it and test. You need to make minor changes as i prepared the query without knowing the correct table structure.

SELECT S.Name,

CASE WHEN s.LAUNCHED is NULL or s.LAUNCHED = ' '
THEN 'UNKNOWN'
ELSE S.LAUNCHED
end as Launched,
B.date,
B.Name
FROM
Ships S INNER JOIN OUTCOMES o on o.ship = S.name,
Battle B INNER JOIN OUTCOMES bo on bo.battle = b.name;

Explanation :

The Outcomes table is joined with Ship table and Battle table to get the the unique records. We have used Case structure to check if the launched column is null or empty. If it is null, it would fill the value as UNKNOWN.