loading..
Русский    English
16:56

Exercise #39 page 4

Notes:

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:

  • damaged;
  • ok;
  • sunk.

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. 

T&S

To solve the problem on SQL-EX.RU

Bookmark and Share
Pages 1 2 3 4
Tags
aggregate functions Airport ALL AND AS keyword ASCII AVG Battles Bezhaev Bismarck C.J.Date calculated columns Cartesian product CASE cast CHAR CHARINDEX Chebykin check constraint classes COALESCE common table expressions comparison predicates Computer firm CONSTRAINT CONVERT correlated subqueries COUNT CROSS APPLY CTE data type conversion data types database schema DATEADD DATEDIFF DATENAME DATEPART DATETIME date_time functions DDL DEFAULT DEFAULT VALUES DELETE DISTINCT DML duplicates edge equi-join EXCEPT exercise (-2) More tags
The book was updated
month ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.