Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1061917
  • 博文数量: 239
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 3618
  • 用 户 组: 普通用户
  • 注册时间: 2012-11-12 13:17
文章分类

全部博文(239)

文章存档

2021年(1)

2016年(1)

2015年(30)

2014年(91)

2013年(116)

分类: Oracle

2015-03-20 00:42:08

6. Examine the structure of the SHIPMENTS table:
name           Null       Type
PO_ID          NOT NULL    NUMBER(3)
PO_DATE        NOT NULL    DATE
SHIPMENT_DATE NOT NULL    DATE
SHIPMENT_MODE             VARCHAR2(30)
SHIPMENT_COST             NUMBER(8,2)
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 THENTO_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. Both execute successfully and give correct results.
B. Only the first query executes successfully but gives a wrong result.
C. Only the first query executes successfully and gives the   correct result.
D. Only the second query executes successfully but gives a wrong result.
E. Only the second query executes successfully and gives the correct result.
Answer: C
答案解析:
显示PO_ID和支付的罚款总金额,SHIPMENT_DATE与PO_DATE进行比较,SHIPMENT_DATE如果比PO_DATE晚一个月,则每天罚款$20。

SQL> CREATE TABLE SHIPMENTS(PO_ID NUMBER(3) NOT NULL,PO_DATE DATE NOT NULL,SHIPMENT_DATE DATE NOT NULL,SHIPMENT_MODE VARCHAR2(30),SHIPMENT_COST NUMBER(8,2));

Table created.

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;

no rows selected

阅读(705) | 评论(0) | 转发(0) |
0

上一篇:1Z0-051-5题

下一篇:1Z0-O51-7题

给主人留下些什么吧!~~