【071题库】最新OCP-071考试题库解析-第49题
071考试是OCP考试科目的一种,由于071考题多变,我们专门收集整理了最新的考试题库,并对这些考题进行讲解,希望可以帮助广大考生。
每周五晚8点,我们有免费的OCP解析公开课,地址:https://ke.qq.com/course/326223 OCP题库交流群:1015267481,验证ocp
-------------------------------------------------------
071题库-第49题、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;)
-
标签错误:<!-- #Label#
labelId=20160707140604
moduleId=1
classId=12231768634
orderby=2
fields=url,title,u_info
attribute=
datatypeId=22192428132
recordCount=3
pageSize=
<htmlTemplate><dt><img src="/images/index_26${index}.jpg" width="100" height="62" /><a href="$url" title="${title}">${title}</a><span>${api.left(u_info,60)}</span></dt></htmlTemplate>
-->
- 我要参加技术沙龙