Exercise #55 page 2 |
||
Solution 3.11.2
The first query in union counts minimal year of launch from Ships table by classes. The second query selects lead ships from Outcomes table (predicate IN) which is absent in Ships table (predicate NOT IN). Such ship takes into account with NULL year of launch, as it was done in solution 3.11.1. But current solution has other mistake. Outcomes table consists ship which is absent in Ships table (e.g. Bismarck ship) but Ships table has other ship of Bismark class with known year of launch. In this case we have two rows on the one class with different year of launch (known year and NULL value). Solution 3.11.2 has completly excessive keyword DISTINCT. The first subquery is using GROUP BY, thats why it doesn`t have duplicates. The second subquery removes duplicates by using UNION. Next, let`s consider solutions without using Outcomes table, but having logical mistakes yet. |