Exercise #70 page 1 |
||
Point out the battles in which at least three ships from the same country took part. Solution 3.7.1
This query may be called a "first approximation" to the solution. All required tables are joined by WHERE clause. After that the battle and the country (from the Classes table) are determined for ships from the Outcomes table. Then the result have got grouped by battle with following selection of ships by count. The mistake covers in fact that we do not take into account ships which is absent in the Ships table. This mistake occurs beacuse we use inner joins. For now it`s should be clear for reader that we do not take into account leading ships. The class of leading ship can be founded not only from Ships table, but also directly from Classes table. Thereupon the owner country can be founded. Now let`s consider solutions containing attempts to take into account this peculiarity. |