免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2458 | 回复: 6
打印 上一主题 下一主题

请教一个ocp的测试题,实在没看懂,哪位有空解答一下,谢谢:) [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2008-01-02 10:57 |只看该作者 |倒序浏览
The employee table contains these columns:
FIRST-NAME VARCHER2(25)
COMISSION NUMBER(3,2)

Evaluate this SQL statement

SELECT first-name,commission
FROM employee
WHERE commission=
(SELECTcomission
FROM employee
WHERE UPPER(first-name)= ‘scott’)

Which statement will cause this statement to fail?

A. Scott has a null commission resolution.
B. Scott has a zero commission resolution.
C. There is no employee with the first name Scott.
D. The first name values in the data base are in the lower case.

这个语句只是没有数据返回
怎么会报错呢?

论坛徽章:
0
2 [报告]
发表于 2008-01-02 13:19 |只看该作者
子查询返回的值是null,
因为 commission = null 是错误的,
should be
commission is null

论坛徽章:
0
3 [报告]
发表于 2008-01-04 14:15 |只看该作者
选择A

论坛徽章:
0
4 [报告]
发表于 2008-01-04 14:25 |只看该作者
a right

论坛徽章:
0
5 [报告]
发表于 2008-01-04 16:19 |只看该作者
题目中的 'scott' 应该是大写吧

论坛徽章:
0
6 [报告]
发表于 2008-01-11 11:06 |只看该作者
做了这样的测试数据:
create table employee (first_name varchar2(20),commission number(10));

insert into employee values ('a',null);
insert into employee values ('b',1);
insert into employee values ('c',1);
insert into employee values ('d',1);
insert into employee values ('scott',1);
insert into employee values ('scott',null);
insert into employee values ('scott',2);

commit;
SELECT first_name,commission
FROM employee
WHERE commission=
(SELECT commission
FROM employee
WHERE UPPER(first_name)= 'scott');

结果没有报错阿

论坛徽章:
0
7 [报告]
发表于 2008-01-11 13:25 |只看该作者
a没有得到想要的结果,从语法上来说,并没有错。
我觉得可能出错的情况就是: 表中有两个或多个记录first name 都是scott
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP