SQL-EX.ru Exercise #36
SQL-EX.ru Exercise #36 I am trying to solve exercise #36 which is List the names of head ships in the database (taking into account Outcomes table) . Head ships are the names of ships that were first in line for that class (i.e. 2 ships but 1 build before another so the first ship is the "head ship"). My result says I did says the following: Your query returned the correct dataset on the first (available) database, but it returned incorrect dataset on the second checking database. * Wrong number of records (less by 1) My query is as follows: SELECT A.name FROM Ships A WHERE A.name = A.class AND A.launched = (SELECT MIN(B.launched) FROM Ships B WHERE A.name = B.name AND A.class = B.class) UNION ALL SELECT A.ship FROM Outcomes A WHERE A.ship IN (SELECT C.ship FROM Outcomes C, Classes D WHERE C.ship IN (SELECT ship FROM Outcomes) AND C.ship NOT IN (SELECT name FROM Ships) AND C.ship = D.class ...