1Z0-051 QUESTION 17 NULL的运算

QUESTION 17
View the E xhibitand examine the data in the EMPLOYEES table.
You want to generate areport showing the total compensation paid to each employee to date.
You issue the followingquery:
SQL>SELECT ename||  ' joined on ' || hiredate ||
', the totalcompensation paid is ' ||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365)* sal + comm)
"COMPENSATION UNTILDATE"
FROM emp;

What is the outcome?


A. It generates an error because the alias is not valid.
B. It executes successfully and gives the correct output.
C. It executes successfully but does not give the correct output.
D. It generates an error because the usage of the ROUND function in the expression is not valid.
E. It generates an error because the concatenation operator can be used to combine only two items.


答案:C

解析:

因为任何数值+NULL都为NULL,因此语句虽然能执行,但结果不对,选C

SQL> SELECT ename||  ' joined on ' || hiredate ||
  2  ', the totalcompensation paid is ' ||
  3  TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365)* sal + comm)
  4  "COMPENSATION UNTILDATE"
  5  FROM employees;

COMPENSATION UNTILDATE
-------------------------------------------------------------------------

SMITH joined on 17-DEC-80, the totalcompensation paid is
ALLEN joined on 20-FEB-81, the totalcompensation paid is 53100
WARD joined on 22-FEB-81, the totalcompensation paid is 41750
JONES joined on 02-APR-81, the totalcompensation paid is
MARTIN joined on 28-SEP-81, the totalcompensation paid is 42650
BLAKE joined on 01-MAY-81, the totalcompensation paid is

6 rows selected.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值