OCP-1Z0-051 第17题 null参与运算后仍是null
来源:互联网 发布:android完整项目源码 编辑:程序博客网 时间:2024/06/03 20:28
一、原题
二、题目翻译
三、题目解析
这条sql语句能执行成功,但因为COMM里有NULL值,参与运算后会得到空值,会使某些行的值不正确。
使用scott用户中的emp表测试如下:
发现上面很多的结果都是空值(null),并没有得到我们想要的结果。
View the Exhibit and examine the data in the EMPLOYEES table.
You want to generate a report showing the total compensation paid to each employee to date.
You issue the following query:
SQL> SELECT ename||' joined on '||hiredate||
', the total compensation paid is '||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
"COMPENSATION UNTIL DATE"
FROM employees;
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
You want to generate a report showing the total compensation paid to each employee to date.
You issue the following query:
SQL> SELECT ename||' joined on '||hiredate||
', the total compensation paid is '||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
"COMPENSATION UNTIL DATE"
FROM employees;
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
二、题目翻译
下图是EMPLOYEES表的数据,现在要生成一个报表,显示每位员工获得的总薪酬。
执行下面的查询语句:
SQL> SELECT ename||' joined on '||hiredate||
', the total compensation paid is '||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
"COMPENSATION UNTIL DATE"
FROM employees;
会产生什么结果?
A. 它产生一个错误,因为别名是无效的。
B. 它执行成功,并且给出正确的输出。
C. 它执行成功,但是没有给出正确结果。
D. 它产生一个错误,因为在表达式中使用ROUND函数是无效的。
E. 它产生一个错误,因为连接操作符只能用来连接两项。
执行下面的查询语句:
SQL> SELECT ename||' joined on '||hiredate||
', the total compensation paid is '||
TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
"COMPENSATION UNTIL DATE"
FROM employees;
会产生什么结果?
A. 它产生一个错误,因为别名是无效的。
B. 它执行成功,并且给出正确的输出。
C. 它执行成功,但是没有给出正确结果。
D. 它产生一个错误,因为在表达式中使用ROUND函数是无效的。
E. 它产生一个错误,因为连接操作符只能用来连接两项。
三、题目解析
这条sql语句能执行成功,但因为COMM里有NULL值,参与运算后会得到空值,会使某些行的值不正确。
使用scott用户中的emp表测试如下:
SQL> SELECT ename||' joined on '||hiredate|| 2 ', the total compensation paid is '||
3 TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
4 "COMPENSATION UNTIL DATE"
5 FROM emp;
COMPENSATION UNTIL DATE
----------------------------------------------------------------------
SMITH joined on 17-DEC-80, the total compensation paid is
ALLEN joined on 20-FEB-81, the total compensation paid is 53100
WARD joined on 22-FEB-81, the total compensation paid is 41750
JONES joined on 02-APR-81, the total compensation paid is
MARTIN joined on 28-SEP-81, the total compensation paid is 42650
BLAKE joined on 01-MAY-81, the total compensation paid is
CLARK joined on 09-JUN-81, the total compensation paid is
SCOTT joined on 19-APR-87, the total compensation paid is
KING joined on 17-NOV-81, the total compensation paid is
TURNER joined on 08-SEP-81, the total compensation paid is 49500
ADAMS joined on 23-MAY-87, the total compensation paid is
COMPENSATION UNTIL DATE
----------------------------------------------------------------------
JAMES joined on 03-DEC-81, the total compensation paid is
FORD joined on 03-DEC-81, the total compensation paid is
MILLER joined on 23-JAN-82, the total compensation paid is
14 rows selected.
3 TO_CHAR(ROUND(ROUND(SYSDATE-hiredate)/365) * sal + comm)
4 "COMPENSATION UNTIL DATE"
5 FROM emp;
COMPENSATION UNTIL DATE
----------------------------------------------------------------------
SMITH joined on 17-DEC-80, the total compensation paid is
ALLEN joined on 20-FEB-81, the total compensation paid is 53100
WARD joined on 22-FEB-81, the total compensation paid is 41750
JONES joined on 02-APR-81, the total compensation paid is
MARTIN joined on 28-SEP-81, the total compensation paid is 42650
BLAKE joined on 01-MAY-81, the total compensation paid is
CLARK joined on 09-JUN-81, the total compensation paid is
SCOTT joined on 19-APR-87, the total compensation paid is
KING joined on 17-NOV-81, the total compensation paid is
TURNER joined on 08-SEP-81, the total compensation paid is 49500
ADAMS joined on 23-MAY-87, the total compensation paid is
COMPENSATION UNTIL DATE
----------------------------------------------------------------------
JAMES joined on 03-DEC-81, the total compensation paid is
FORD joined on 03-DEC-81, the total compensation paid is
MILLER joined on 23-JAN-82, the total compensation paid is
14 rows selected.
发现上面很多的结果都是空值(null),并没有得到我们想要的结果。
0 0
- OCP-1Z0-051 第17题 null参与运算后仍是null
- OCP-1Z0-051 第59题 null值判断
- OCP-1Z0-051 第163题 判断null值
- OCP-1Z0-051 第57题 别名和null值判断
- OCP-1Z0-051 第69题 ORDER BY 的null值排序
- OCP-1Z0-051 第146题 子查询中的null值
- OCP-1Z0-051 补充题库 第30题 oracle中的NULL值
- 1Z0-051 QUESTION 17 NULL的运算
- OCP-1Z0-051 第11题 sql运算顺序
- OCP-1Z0-051 第10题
- OCP-1Z0-051 第54题
- OCP-1Z0-051 第60题
- OCP-1Z0-051-题目解析-第17题
- OCP-1Z0-051 第150题 集合运算MINUS,INTERSECT
- OCP-1Z0-051 补充题库 第39题 日期运算
- sql字段null参与运算 sql date
- OCP-1Z0-051-2015-17题
- OCP-1Z0-051-题目解析-第1题
- 垃圾清理势在必行——java垃圾收集算法
- CMAKE 编译 PCL库的kinfu
- Block 3:__block说明符
- aclocal安装依赖的库
- 理解和使用NT驱动程序的执行上下文
- OCP-1Z0-051 第17题 null参与运算后仍是null
- 基于HttpClient4.3实现的Http后台请求
- s5pv210 cmos摄像头驱动(二)
- cocos2d-x 新手上路
- 代码面试最常用的10大算法
- HTML Entities & Charset & URL Encode
- Android布局之LinearLayout与TableLayout的嵌套使用
- 黑马程序员:查表法解决进制转换
- 学习笔记_web——表单验证