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

Exercise #151 page 1

Define the names of all the ships in the database which were definitely launched before 1941.

Despite of complexity level of 2, the solution of this exercise have caused, apparently, the greatest difficulties. And these are not due to complexity in construction of query, but due to logic of the solution of a problem.

Until recently this task has been formulated as: «Define the names of all ships, which were launched before 1918.». It seemingly has no difference, hasn't it? Does the following decision not be a correct?

Solution 3.5.1

Console
Execute
  1. SELECT name AS shipName
  2. FROM Ships
  3. WHERE launched < 1941;

No. As it has fairly been noticed by visitors of a site, dates of battles are not considered here in any way. Really, the ship is necessary to include into the result set, if the year of launching of the ship, which took part in the battle before 1941, is unknown. In the initial formulation of this problem where year 1918 was presented, there was possible to not care about it, as the database formally contains the information on battles of the World War II which has begun in 1939.


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
several days ago
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.