• OCP-1Z0-051-V9.02-147题


    147. View the Exhibit and examine the structure of the PROMOTIONS table.

    Evaluate the following SQL statement: 

    SQL>SELECT promo_name,CASE   

    WHEN promo_cost >=(SELECT AVG(promo_cost)      

    FROM promotions      

    WHERE promo_category='TV')        

    then 'HIGH'        

    else 'LOW'        

    END COST_REMARK

    FROM promotions;

    Which statement is true regarding the outcome of the above query?

    A. It shows COST_REMARK for all the promos in the table. 分类显示所有值

    B. It produces an error because the subquery gives an error.

    C. It shows COST_REMARK for all the promos in the promo category 'TV'.

    D. It produces an error because subqueries cannot be used with the CASE expression.

    Answer: A

    答案解析:

    1、首先运行子查询,得出一个数值

     

    sh@TEST0910> SELECT AVG(promo_cost) FROM promotions  WHERE promo_category='TV';
    AVG(PROMO_COST)
    ---------------
         46260.8696

    2、所有的promos 根据上面计算的数值,来进行分类。故选择A

    sh@TEST0910> SELECT promo_name,CASE WHEN promo_cost >=
      2  (SELECT AVG(promo_cost) FROM promotions  WHERE promo_category='TV')
      3  then 'HIGH'  else 'LOW'END COST_REMARK
      4  FROM promotions;
    PROMO_NAME                     COST
    ------------------------------ ----
    NO PROMOTION #                 LOW
    newspaper promotion #16-108    LOW
    post promotion #20-232         LOW
    newspaper promotion #16-349    LOW
    internet promotion #14-471     LOW
  • 相关阅读:
    研究生数学建模历年题目汇总
    【20220902】成年人的美好
    【20220831】恶梦
    【20220827】连岳摘抄
    【20220903】连岳摘抄
    【20220904】勇气之笔
    【20220905】珍惜时光
    【20220901】连岳摘抄
    【20220830】哺乳
    【力扣 056】123. 买卖股票的最佳时机 III
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317215.html
Copyright © 2020-2023  润新知