Exercise #(-2) page 1 |
|||||||||||||||||||||||||||||||||||||||||||||
It is necessary to determine year when maximum quantity of ships had been launched for each country. If there were several diffirent years with maximum value, the minimal one must be returned. On the output: country, quantity of ships, year. Solution 3.6.1. Here is a typical beginner’s solution:
The subquery in FROM clause determines quantity of rows for each unique pair {country, year of launch}. In the terms of the data domain this means that it is determined quantity of ships that had been launched by every single country in every year. Let the resultant set of the subquery “s” will be the following:
Next, in the WHERE clause it will be selected rows with year of launch that matches any year from this subquery:
What this subquery gives us? It gives us all years from the table above, because the data is grouped by country and year. As result this subquery doesn't take any effect to the data set, therefore it is unnecessary. It seemes that author want to express the minimal year condition in this expression. But the minimal year must be considered as minumum of those years in which maximum ships’ quantity for this country had been launched. |