ITPub博客

首页 > 数据库 > Oracle > OCP 1Z0-051-64

OCP 1Z0-051-64

原创 Oracle 作者:LuiseDalian 时间:2014-05-15 07:28:17 0 删除 编辑
(64)View the Exhibit and examine the data in the PROMO_CATEGORY and PROMO_COST columns of the PROMOTIONS table.

Evaluate the following two queries:

SELECT DISTINCT promo_category, to_char(promo_cost) "code"

FROM promotions ORDER BY code;

SELECT DISTINCT promo_category, promo_cost "code"

FROM promotions ORDER BY 1;

Which statement is true regarding the execution of the above queries?

A. Only the first query executes successfully.

B. Only the second query executes successfully.

C. Both queries execute successfully but give different results.

D. Both queries execute successfully and give the same result.

答案:(B)

解析:

--A(X), 列的别名加了引号,order by中别名也必须加引号

scott@TESTDB11>select sal, ename as "name" from emp order by name;

select sal, ename as "name" from emp order by name

                                              *

ERROR at line 1:

ORA-00904: "NAME": invalid identifier

scott@TESTDB11>select sal, ename as "name" from emp order by "name";

       SAL name

---------- ----------

      1100 ADAMS

      1600 ALLEN

      2850 BLAKE

      2450 CLARK

      3000 FORD

       950 JAMES

      2975 JONES

      5000 KING

      1250 MARTIN

      1300 MILLER

      3000 SCOTT

       800 SMITH

      1500 TURNER

      1250 WARD

14 rows selected.



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/17013648/viewspace-1161528/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: OCP 1Z0-051-69
下一篇: OCP 1Z0-051-66
请登录后发表评论 登录
全部评论

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    6043834