ITPub博客

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

OCP 1Z0-051-113

原创 Oracle 作者:LuiseDalian 时间:2014-05-21 06:36:49 0 删除 编辑
(113)Examine the structure of the ORDERS table:

Name                  Null          Type

ORDER_ID         NOT NULL NUMBER(12)

ORDER_DATE    NOT NULL TIMESTAMP(6)

CUSTOMER_ID   NOT NULL NUMBER(6)

ORDER_STATUS                  NUMBER(2)

ORDER_TOTAL                    NUMBER(8,2)

You want to find the total value of all the orders for each year and issue the following command:

SELECT TO_CHAR(order_date,'rr'), SUM(order_total)

FROM orders

GROUP BY TO_CHAR(order_date,'yyyy');

Which statement is true regarding the outcome?

A. It executes successfully and gives the correct output.

B. It gives an error because the TO_CHAR function is not valid.

C. It executes successfully but does not give the correct output.

D. It gives an error because the data type conversion in the SELECT list does not match the data type conversion in the GROUP BY clause.

答案:(D)

解析:

scott@TESTDB11>select to_char(hiredate, 'rr'), sum(sal)

  2  from emp

  3  group by to_char(hiredate, 'yyyy');

select to_char(hiredate, 'rr'), sum(sal)

               *

ERROR at line 1:

ORA-00979: not a GROUP BY expression

--要求没有出现在聚合函数中的列,必须出现在group by子句中,而且形式必须一致

scott@TESTDB11>select to_char(hiredate, 'rr'), sum(sal)

  2  from emp

  3  group by to_char(hiredate, 'rr');

TO   SUM(SAL)

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

87       5100

81      22925

82       1300

80       1800

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

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

注册时间:2012-02-06

  • 博文量
    1986
  • 访问量
    6040864