一、原题
二、题目翻译
三、题目解析
View the Exhibit and evaluate structures of the SALES, PRODUCTS, and COSTS tables.
![](https://img-blog.csdn.net/20140521001533343?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvaG9sbHkyMDA4/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/SouthEast)
Evaluate the following SQL statement:
SQL>SELECT prod_id FROM products
INTERSECT
SELECT prod_id FROM sales
MINUS
SELECT prod_id FROM costs;
Which statement is true regarding the above compound query?
A. It produces an error.
B. It shows products that were sold and have a cost recorded.
C. It shows products that were sold but have no cost recorded.
D. It shows products that have a cost recorded irrespective of sales.
答案:C
Evaluate the following SQL statement:
SQL>SELECT prod_id FROM products
INTERSECT
SELECT prod_id FROM sales
MINUS
SELECT prod_id FROM costs;
Which statement is true regarding the above compound query?
A. It produces an error.
B. It shows products that were sold and have a cost recorded.
C. It shows products that were sold but have no cost recorded.
D. It shows products that have a cost recorded irrespective of sales.
答案:C
二、题目翻译
查看SALES, PRODUCTS, and COSTS表的结构:
评估下面的SQL语句:
关于上面的组合查询哪句话是正确的:
A.报错。
B.显示已销售并且有cost记录的产品。
C.显示已销售但是没有cost记录的产品。
D.显示有cost recorded不管sales的产品。
评估下面的SQL语句:
关于上面的组合查询哪句话是正确的:
A.报错。
B.显示已销售并且有cost记录的产品。
C.显示已销售但是没有cost记录的产品。
D.显示有cost recorded不管sales的产品。
三、题目解析
SELECT prod_id FROM products
INTERSECT
SELECT prod_id FROM sales
首先,交集,求出的是已经销售的产品ID
然后再和costs表和差集,表示已销售但是没有cost记录的产品。
INTERSECT
SELECT prod_id FROM sales
首先,交集,求出的是已经销售的产品ID
然后再和costs表和差集,表示已销售但是没有cost记录的产品。