• 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.
  • 相关阅读:
    (转)JQuery中$.ajax()方法参数详解
    __dopostback的用法 . 编辑
    (转)__dopostback的用法 .
    (转)如何区分一个程序员是“老手“还是“新手“?
    jQuery验证框架 .
    location.href的用法
    为用户设置密码
    设置环境变量
    用 xampp 在ubuntu 下配置php 运行环境 lampp
    安装与配置JDK
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13317160.html
Copyright © 2020-2023  润新知