设为首页 加入收藏

TOP

ocp 1Z0-051 71-105题解析(五)
2014-11-24 00:37:21 来源: 作者: 【 】 浏览:62
Tags:ocp 1Z0-051 71-105 解析
cause fm and double quotation marks should not be used in the format string.

Answer: A

解析:

TO_CHAR(NEXT_DAY(LAST_DAY(SYSDATE),'MON')

LAST_DAY(SYSDATE)返回当月最后一天

NEXT_DAY(LAST_DAY(SYSDATE),'MON')返回LAST_DAY(SYSDATE)后由'MON'指定的第一个工作日对应的日期

88. You need tocalculate the number of days from 1st January 2007 till date.

Dates are stored in thedefault format of dd-mon-rr.

Which SQL statementswould give the required output (Choose two .)

A. SELECT SYSDATE -'01-JAN-2007' FROM DUAL;

B. SELECT SYSDATE -TO_DATE('01/JANUARY/2007') FROM DUAL;

C. SELECT SYSDATE -TO_DATE('01-JANUARY-2007') FROM DUAL;

D. SELECTTO_CHAR(SYSDATE, 'DD-MON-YYYY') - '01-JAN-2007' FROM DUAL;

E. SELECT TO_DATE(SYSDATE,'DD/MONTH/YYYY') - '01/JANUARY/2007' FROM DUAL;

Answer: BC

解析:

A选项,'01-JAN-20’无法转换为sysdate格式

To_date 将符合格式的字符串转换为日期,和sysdate格式一样

B C正确

D选项,即使转换为字符串,也无法相比

Character values are compared on the basis of twomeasures:

■ Binary or linguistic sorting

■ Blank-padded or nonpadded comparison semantics

sys@ORCL>select '01-FEB-2010'-'01-JAN-2007' from dual;

select '01-FEB-2010'-'01-JAN-2007' from dual

*

第 1 行出现错误:

ORA-01722: 无效数字

E选项转换后和A项相同

89. You need to displaythe date 11-oct-2007 in words as 'Eleventh of October, Two Thousand Seven'.

Which SQL statementwould give the required result

A. SELECTTO_CHAR('11-oct-2007', 'fmDdspth "of" Month, Year')

FROM DUAL;

B. SELECTTO_CHAR(TO_DATE('11-oct-2007'), 'fmDdspth of month, year')

FROM DUAL;

C. SELECTTO_CHAR(TO_DATE('11-oct-2007'), 'fmDdthsp "of" Month, Year')

FROM DUAL;

D. SELECTTO_DATE(TO_CHAR('11-oct-2007','fmDdspth ''of'' Month, Year'))

FROM DUAL;

Answer: C

解析:

sys@ORCL>SELECT TO_CHAR(TO_DATE('11-10月-2007'), 'fmDdthsp "of" Month, Year')

2 from dual;

TO_CHAR(TO_DATE('11-10月-2007'),'FMD

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

Eleventh of 10月, Two ThousandSeven

90. Examine thestructure and data in the PRICE_LIST table:

name Null Type

PROD_ID NOT NULLNUMBER(3)

PROD_PRICE VARCHAR2(10)

PROD_ID PROD_PRICE

100 $234.55

101 $6,509.75

102 $1,234

You plan to give adiscount of 25% on the product price and need to display the discount amount inthe

same format as thePROD_PRICE.

Which SQL statementwould give the required result

A. SELECTTO_CHAR(prod_price* .25,'$99,999.99')

FROM PRICE_LIST;

B. SELECTTO_CHAR(TO_NUMBER(prod_price)* .25,'$99,999.00')

FROM PRICE_LIST;

C. SELECTTO_CHAR(TO_NUMBER(prod_price,'$99,999.99')* .25,'$99,999.00')

FROM PRICE_LIST;

D. SELECTTO_NUMBER(TO_NUMBER(prod_price,'$99,999.99')* .25,'$99,999.00')

FROM PRICE_LIST;

Answer: C

解析:

需要先将价格转换为数字再进行运算

TO_NUMBER(prod_price,'$99,999.99')* .25 将符合特定格式的字符串转换为数值

当然运算完成,再转换为价格的格式

TO_CHAR(TO_NUMBER(prod_price,'$99,999.99')*.25,'$99,999.00')

更多格式说明:
http://blog.csdn.net/zbdba/article/details/17042195

91. View the Exhibit andexamine the structure of the PROMOTIONS table.

Which two SQL statementswould execute successfully (Choose two.)

\

A. UPDATE promotions

SET promo_cost =promo_cost+ 100

WHERETO_CHAR(promo_end_date, 'yyyy') > '2000';

B. SELECTpromo_begin_date

FROM promotions

WHERETO_CHAR(promo_begin_date,'mon dd yy')='jul 01 98';

C. UPDATE promotions

SET promo_cost =promo_cost+ 100

WHERE promo_end_date> TO_DATE(SUBSTR('01-JAN-2000',8));

D. SELECTTO_CHAR(promo_begin_date,'dd/month')

FROM promotions

WHERE promo_begin_dateIN (TO_DATE('JUN 01 98')

首页 上一页 2 3 4 5 6 7 8 下一页 尾页 5/10/10
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇UNION和UNION ALL两者之间在性能.. 下一篇在Contos下安装tomcat6.0.29

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: