标题: 跟crackman做sas adv认证试题(2) [打印本页] 作者: shiyiming 时间: 2010-11-15 23:16 标题: 跟crackman做sas adv认证试题(2) From crackman's blog on Baidu
<p><font size="4" face="宋体">Given the SAS data sets: <br>
<br>
WORK.EMPLOYEE WORK.NEWEMPLOYEE <br>
<br>
Name Dept Names Salary <br>
-------- ----- -------- ------ <br>
Alan Sales Michelle 50000 <br>
Michelle Sales Paresh 60000 <br>
<br>
A SAS program is submitted and<br>
the following is written to the SAS log: <br>
<br>
101 proc sql;<br>
102 select dept, name <br>
103 from WORK.EMPLOYEE <br>
104 where name=(select names<br>
from newemployee <br>
where salary > 40000) <br>
ERROR: Subquery evaluated to more than one row. <br>
105 ; <br>
106 quit; <br>
<br>
What would allow the program to<br>
successfully execute without errors? </font></p>
<p><br>
<font size="4" face="宋体">A.Replace the where clause with: <br>
<br>
where EMPLOYEE.Name=(select Names delimited with ',' <br>
from WORK.NEWEMPLOYEE<br>
where Salary > 40000); <br>
<br>
B.Replace line 104 with: <br>
<br>
where EMPLOYEE.Name =ANY (select Names separated with ',' <br>
from WORK.NEWEMPLOYEE <br>
where Salary > 40000);<br>
C.Replace the equal sign with the IN operator.<br>
<br>
D.Qualify the column names with the table names. </font></p>
<p><font size="4" face="宋体">答案为C。<br>
本文属于博客:</font><a href="http://hi.baidu.com/crack_man/home"><font size="4" face="宋体"><!-- m --><a class="postlink" href="http://hi.baidu.com/crack_man/home">http://hi.baidu.com/crack_man/home</a><!-- m --></font></a><font size="4" face="宋体"> 版权归作者所有,欢迎转载!如有转载,请务必注明出处!未经本文作者同意不得用于商业应用。<br>
首先分析这个原程序第104行,中where name=(select names from newemployee where salsry>40000)<br>
原程序在执行过程,应先是执行子查询,select names from newemployee where salsry>40000,将返回的结果作为下一个查询的筛选条件。<br>
在这里返回的结果NAMES这个变量包括了两个值Michelle和Paresh,所以在执行过程出现错误。那么应该改成 IN或者ANY。IN ANY指定的是一个匹配范围,而等号必须是一个具体匹配的值。<br>
这里可以思考SEPARATED WITH这个语句,SAS认为是错误。</font></p>
<p> </p> <a href="http://hi.baidu.com/crack%5Fman/blog/item/a524fe077f8ddafc09fa9368.html">阅读全文</a>