Русский    English

Exercise #20

Find the makers producing at least three distinct models of PCs. Result set: maker, number of models.

The beginners frequently ask: "Why the answer for this task is estimated by the system as correct that the producer E has three distinct models, whereas the query


  1. SELECT Product.maker, PC.model
  2. FROM PC, Product
  3. WHERE Product.model=PC.model;
give us only one model for this producer?"  

Models which are produced in principle are in the Product table. We can say that the PC table contains only the PCs available now. Join of tables restrict result set only by the models (more correctly, PC units) available in PC table.

Since the exercise asks us about models but not about PCs, only the Product table is to be analysed; as a result the missing models will be found.

To solve the problem on SQL-EX.RU

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