一、原题
二、题目翻译
三、题目解析
View the Exhibit and examine the structure of the SALES and PRODUCTS tables.
In the SALES table, PROD_ID is the foreign key referencing PROD_ID in the PRODUCTS table,
You want to list each product ID and the number of times it has been sold.
Evaluate the following query:
SQL>SELECT p.prod_id, COUNT(s.prod_id)
FROM products p _____________ sales s
ON p.prod_id = s.prod_id
GROUP BY p.prod_id;
Which two JOIN options can be used in the blank in the above query to get the required output? (Choose two.)
A. JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
答案:BC
In the SALES table, PROD_ID is the foreign key referencing PROD_ID in the PRODUCTS table,
You want to list each product ID and the number of times it has been sold.
Evaluate the following query:
SQL>SELECT p.prod_id, COUNT(s.prod_id)
FROM products p _____________ sales s
ON p.prod_id = s.prod_id
GROUP BY p.prod_id;
Which two JOIN options can be used in the blank in the above query to get the required output? (Choose two.)
A. JOIN
B. FULL OUTER JOIN
C. LEFT OUTER JOIN
D. RIGHT OUTER JOIN
答案:BC
二、题目翻译
查看SALES和PRODUCTS表的结构:
SALES表中,PROD_ID是关联PRODUCTS表的外键。
列出每一个产品ID和产品已销售的次数。
评估下面的查询:
哪两个join填在空格处能得出所需的结果?
SALES表中,PROD_ID是关联PRODUCTS表的外键。
列出每一个产品ID和产品已销售的次数。
评估下面的查询:
哪两个join填在空格处能得出所需的结果?
三、题目解析
列出每一个产品ID,应该使用LEFT JOIN,C选项正确,
由于s表的prod_id是products表的外键,不会出现s表中有,而p表中匹配不上的现象,所以在这里,FULL JOIN的效果和LEFT JOIN一样的。
表连接的用法,详见:
http://blog.csdn.net/holly2008/article/details/25704471
由于s表的prod_id是products表的外键,不会出现s表中有,而p表中匹配不上的现象,所以在这里,FULL JOIN的效果和LEFT JOIN一样的。
表连接的用法,详见:
http://blog.csdn.net/holly2008/article/details/25704471