Exercise #39 page 4
In the context of last predicate it would be desirable to remind readers, that inquiries which we analyze, have been written by visitors of SQL-EX.RU site. The made mistakes are not far-fetched, but are naturally due to process of training when the formal knowledge of the programming language is applied to the decision of specific task. Actually, this book is also written to facilitate transition from formal knowledge to practical skills.
However let's return to a wording. According to the description of a subject area, the ship can be:
That's why the condition min( result) = 'damaged' will be executed, if a ship was damaged in one of the battles (under the natural sorting of the text strings the letter "D" goes earlier that the letters "O" and "S"). However, it doesn't quite mean that it had been damaged before it took part in the next battle that is required by the terms of the task. Here we need to appreciate the date of the battle. As concerns about MAX(result) = 'damaged', then this condition will not be executed, if the results of the battles were different; and if similar, then it will give nothing new in comparison with the first condition on minimum.
And such a superposition of the mistakes gave the right result on the both databases. Precautions have already been taken - test data had been added, and the current solution gives the wrong result now. As it should be.