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

Exercise #7 page 3

It is possible to use a table join instead of the IN predicate; however, SQL Server builds identical execution plans for both cases.


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';

Queries based on table joins can be an alternative to union queries. For this particular task, such a solution has a less efficient execution plan, but in other cases it may prove to be preferable. Anyway, for learning purposes, it makes sense to try different ways of solving the task, which is left as an exercise to the reader.

T&S

Solve this task at SQL-EX.RU

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