zoukankan      html  css  js  c++  java
  • OCP-1Z0-051-V9.02-155题

    155. Evaluate the following SQL statement:

    SQL> SELECT promo_id, promo_category

    FROM promotions

    WHERE promo_category = 'Internet' ORDER BY 2 DESC

    UNION

    SELECT promo_id, promo_category

    FROM promotions

    WHERE promo_category = 'TV'

    UNION

    SELECT promo_id, promo_category

    FROM promotions
    WHERE promo_category ='Radio';

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

    A. It executes successfully and displays rows in the descending order of PROMO_CATEGORY.

    B. It produces an error because positional notation cannot be used in the  ORDER BY clause with SET

    operators.

    C. It executes successfully but ignores the ORDER BY clause because it is not located at the end of the

    compound statement.

    D. It produces an error because the ORDER BY clause should appear only at the end of a compound

    query-that is, with the last SELECT statement.  ORDER BY必须要在句子最后

    Answer: D
     
    答案解析:
    ORDER BY 子句应该放在复合sql查询语句的最后。
     
    sh@TEST0924> SELECT promo_id, promo_category
      2  FROM promotions
      3  WHERE promo_category = 'Internet' ORDER BY 2 DESC
      4  UNION
      5  SELECT promo_id, promo_category
      6  FROM promotions
      7  WHERE promo_category = 'TV'
      8  UNION
      9  SELECT promo_id, promo_category
     10  FROM promotions
     11  WHERE promo_category ='Radio';
    UNION
    *
    ERROR at line 4:
    ORA-00933: SQL command not properly ended
    正确的是:
    sh@TEST0924> SELECT promo_id, promo_category
      2  FROM promotions
      3  WHERE promo_category = 'Internet'
      4  UNION
      5  SELECT promo_id, promo_category
      6  FROM promotions
      7  WHERE promo_category = 'TV'
      8  UNION
      9  SELECT promo_id, promo_category
     10  FROM promotions
     11  WHERE promo_category ='Radio'
     12  ORDER BY 2 DESC;
     
      PROMO_ID PROMO_CATEGORY
    ---------- ------------------------------
            35 TV
            42 TV
            47 TV
            49 TV
            54 TV
    ...
           532 TV
           534 TV
     
    115 rows selected.
  • 相关阅读:
    CLBZDQ
    CF1559D 题解
    DP 的凸优化
    正睿暑期集训7B
    基于 TiSpark 的海量数据批量处理技术
    PowerDesigner16.5下载和安装教程
    使用TiDB MPP
    使用 TiDB 构建实时应用
    oracle转mysql数据库
    kafka-jdbc-connector-sink实现kafka中的数据同步到mysql
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317160.html
Copyright © 2011-2022 走看看