全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
3015 0
2010-11-15
Given the SAS data sets:      

   WORK.EMPLOYEE            WORK.NEWEMPLOYEE   

   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认为是错误。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群