OCP-1Z0-051-2015-38题

来源:互联网 发布:网络教育本科能考研吗 编辑:程序博客网 时间:2024/06/05 19:28

See the Exhibit and Examine the structure of the CUSTOMERS table:

Using the CUSTOMERS table, you need to generate a report that shows an increase in the credit
limit by 15% for all customers. Customers whose credit limit has not been entered should have the
message "Not Available" displayed.
Which SQL statement would produce the required result?
A.SELECT NVL(cust_credit_limit,'Not Available')*.15 "NEW CREDIT" FROM customers;
B. SELECT NVL(cust_credit_limit*.15,'Not Available') "NEW CREDIT" FROM customers;
C. SELECT TO_CHAR(NVL(cust_credit_limit*.15,'Not Available')) "NEW CREDIT" FROM
customers;
D. SELECT NVL(TO_CHAR(cust_credit_limit*.15),'Not Available') "NEW CREDIT" FROM
customers;
Answer: D
Explanation:根据题意增加用户信用度百分之15

格式NVL(expr1,expr2)如果expr1是null,则返回expr2,如果expr1 is not null,则返回expr1.

此处考试的意图在与NVL函数里参数的数据类型的一致性以及数据类型之间的转换。

expr1 and expr2 可以是任意的数据类型,但他们必须是同一数据类型,或者是隐式转换为同一数据类型,又或者是显示转换为同一数据类型。

如果他们不是同一类型,则报错。

由题意可知,先用同to_char函数显示将cust_credit_limit*.15转换为字符类型,才能达成数据类型一致。


NVL Function
Converts a null value to an actual value:
Data types that can be used are date, character, and number.日期、字符、数字型
Data types must match:
– NVL(commission_pct,0)
– NVL(hire_date,'01-JAN-97')

– NVL(job_id,'No Job Yet')

0 0
原创粉丝点击