Name Dept Names Salary
-------- ----- -------- ------
Alan Sales Michelle 50000
Michelle Sales Paresh 60000
A SAS program is submitted and
the following is written to the SAS log:
101 proc sql;
102 select dept, name
103 from WORK.EMPLOYEE
104 where name=(select names
from newemployee
where salary > 40000)
ERROR: Subquery evaluated to more than one row.
105 ;
106 quit;
What would allow the program to
successfully execute without errors?
A.Replace the where clause with:
where EMPLOYEE.Name=(select Names delimited with ','
from WORK.NEWEMPLOYEE
where Salary > 40000);
B.Replace line 104 with:
where EMPLOYEE.Name =ANY (select Names separated with ','
from WORK.NEWEMPLOYEE
where Salary > 40000);
C.Replace the equal sign with the IN operator.
D.Qualify the column names with the table names.
答案为C。
本文属于博客:http://crackman.net/ 版权归作者所有,欢迎转载!如有转载,请务必注明出处!未经本文作者同意不得用于商业应用。
首先分析这个原程序第104行,中where name=(select names from newemployee where salsry>40000)
原程序在执行过程,应先是执行子查询,select names from newemployee where salsry>40000,将返回的结果作为下一个查询的筛选条件。
在这里返回的结果NAMES这个变量包括了两个值Michelle和Paresh,所以在执行过程出现错误。那么应该改成 IN或者ANY。IN ANY指定的是一个匹配范围,而等号必须是一个具体匹配的值。
这里可以思考SEPARATED WITH这个语句,SAS认为是错误。