您的位置:首页 > 产品设计 > UI/UE

OCP-1Z0-051 第149题 子查询中ALL的应用

2014-05-22 13:45 411 查看
一、原题

View the Exhibits and examine the structures of the COSTS and PROMOTIONS tables.



Evaluate the following SQL statement:
SQL>SELECT prod_id

      FROM costs

     WHERE promo_id IN

           (SELECT promo_id

              FROM promotions

             WHERE promo_cost < ALL

             (SELECT MAX(promo_cost)

                      FROM promotions

                     GROUP BY (promo_end_date - promo_begin_date)));
What would be the outcome of the above SQL statement?

A. It displays prod IDs in the promo with the lowest cost.

B. It displays prod IDs in the promos with the lowest cost in the same time interval.

C. It displays prod IDs in the promos with the highest cost in the same time interval.
D. It displays prod IDs in the promos with cost less than the highest cost in the same time interval.

答案:D

二、题目翻译

查看COSTS and PROMOTIONS表的结构.

评估下面的SQL语句

上面SQL的执行结果什么?

A.显示promo最低的prod IDs。

B.显示相同时间段内promo最低的prod IDs。

C.显示相同时间段内promo最高的prod IDs。

D.显示相同时间段内promo的cost小于最高的cost的prod IDs。

三、题目解析

子查询
SELECT MAX(promo_cost)

  FROM promotions

 GROUP BY (promo_end_date - promo_begin_date)

求出来的,是每个促销活动期间内的最大的成本。

然后 promo_cost < ALL(.. ),表示小于 刚子查询查出来的所有这些最大成本结果集中,最小的那个。

然后,再根据活动ID,查出产品ID。

D选项中,描述也不是太准确,但是在几个选项的描述中,D是最接近的。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息