OCP-1Z0-051-V9.02-149题

149. 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.

Answer: D

 

答案解析:

1、首先查询出promo_end_date- promo_begin_date期间promo_cost的最大值

sh@TEST0924> SELECT MAX(promo_cost) FROM promotions
  2  GROUP BY (promo_end_date- promo_begin_date);
 
MAX(PROMO_COST)
---------------
              0
          98500
              0
          99900
         100000
          99000
          99300
          95900
          99600
          98000
 
10 rows selected.
 
2、<ALL,即小于1查询出来所有的的值,即小于最小值。
3、按题中查询,即查询出小于MAX(promo_cost) 的所有的值。
sh@TEST0924>  SELECT prod_id FROM costs
  2  WHERE promo_id IN  (SELECT promo_id FROM promotions
  3  WHERE promo_cost < ALL
  4  (SELECT MAX(promo_cost) FROM promotions
  5  GROUP BY (promo_end_date-
  6  promo_begin_date)));
 
 
no rows selected
 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值