码迷,mamicode.com
首页 > 其他好文 > 详细

【12c OCP】最新CUUG OCP-071考试题库(49题)

时间:2019-03-01 12:29:07      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:reg   pen   最新   sele   exe   load   case   .com   img   

49、(11-1) choose the best answer

Examine the structure of the SHIPMENTS table:

技术图片

You want to generate a report that displays the PO_ID and the penalty amount to be paid(罚款数额) if the SHIPMENT_DATE is later than one month from the PO_DATE. The penalty is $20 per day.

Evaluate the following two queries:

SQL> SELECT po_id, CASE

WHEN MONTHS_BETWEEN (shipment_date,po_date)>1 THEN

TO_CHAR((shipment_date - po_date)*20) ELSE ‘No Penalty‘ END PENALTY

FROM shipments;

SQL>SELECT po_id, DECODE

(MONTHS_BETWEEN(po_date,shipment_date)>1,

TO_CHAR((shipment_date - po_date) * 20, ‘NO Penalty‘) PENALTY

FROM shipments;

Which statement is true regarding the above commands?

A) Only the second query executes successfully but gives a wrong result.

B) Only the second query executes successfully and gives the correct result.

C) Only the first query executes successfully but gives a wrong result.

D) Both execute successfully and give correct results.

E) Only the first query executes successfully and gives the correct result.

Answer:E

(解析:decode 函数的语法是,decode(条件,值 1,返回值 1,值 2,返回值 2,...值 n,返回值 n,缺省值),

所以不能有>1 的条件判断。原来 051 的题。

该语句可以改写为下面的语句:

SELECT empno,hiredate,

CASE

WHEN MONTHS_BETWEEN (sysdate,hiredate)>1

THEN TO_CHAR((sysdate - hiredate )*20)

ELSE ‘No Penalty‘

END PENALTY

 

FROM emp;)

【12c OCP】最新CUUG OCP-071考试题库(49题)

标签:reg   pen   最新   sele   exe   load   case   .com   img   

原文地址:https://www.cnblogs.com/cnblogs5359/p/10455579.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!