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

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


Console
Execute
  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.

T&S

To solve the problem on SQL-EX.RU

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