Русский    English

Exercise #7 page 3

It is possible to use join instead of IN predicate, however SQL Server gives for these two cases identical execution plans

  1. SELECT a.model, price
  2. FROM (SELECT model, price
  3. FROM PC
  4. UNION
  5. SELECT model, price
  6. FROM Laptop
  7. UNION
  8. SELECT model, price
  9. FROM Printer
  10. ) AS a JOIN
  11. Product p ON a.model = p.model
  12. WHERE p.maker = 'B';

The alternative to the queries, that use the union, may be the queries implying join. For this problem such a solution will have less efficient execution plan, although in other cases it can prove to be preferable. In any case, for educative purposes it will be useful to consider different ways of solution of the problem, we suggest you to do it on your own.


To solve the problem on SQL-EX.RU

Bookmark and Share
Pages 1 2 3
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.