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

Exercise #39 page 2

Solution 3.4.2. The same result gives solution which uses self-join:

Console
Execute
  1. SELECT DISTINCT o.ship
  2. FROM Outcomes AS o, Outcomes AS o2
  3. WHERE (o.result = 'damaged' OR
  4.        o2.result = 'damaged'
  5.        ) AND
  6.        o.battle <> o2.battle AND
  7.        o.ship = o2.ship;

Here is applied the join of Outcomes table with itself provided that ship is the same, but fights are different. Besides, the ship has been damaged in one of fights. As easy to see, there was no check of a battle in which the ship has been damaged for earlier date.


Bookmark and Share
Pages 1 2 3 4
The book was updated
yesterday
©SQL-EX,2008 [Evolution] [Feedback] [About] [Links] [Team]
All right reserved.
Rambler's Top100