loading..
Русский    English
15:59

Exercise #70 (tips and solutions)

Here we want to consider some transparent solution with two slight mistakes. Here is it (pay attention on commentaries):

Console
Execute
  1. SELECT q.battle
  2. FROM (
  3. --Determine ships from Ships table which taking part in battles
  4. SELECT Outcomes.battle, Outcomes.ship, Classes.country
  5. FROM Classes INNER JOIN
  6. Ships ON Classes.class = Ships.class INNER JOIN
  7. Outcomes ON Ships.name = Outcomes.ship
  8. UNION
  9. --Determine leading ships from the Outcomes table
  10. SELECT Outcomes.battle, Outcomes.ship, Classes.country
  11. FROM Outcomes INNER JOIN
  12. Classes ON Outcomes.ship = Classes.class
  13. ) AS q
  14. GROUP BY q.battle
  15. HAVING COUNT(q.country) >= 3;

We hope that you`ll easily find this two mistakes and correct it.

To return to discussion of exercise #70

To solve a problem on SQL-EX.RU

Bookmark and Share
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.