SAS中文论坛

标题: SAS SQL 高手请进 [打印本页]

作者: shiyiming    时间: 2010-5-30 09:53
标题: SAS SQL 高手请进
Complete the following PROC SQL query to select the columns Address and SqFeet from the table List.Size and to select Price from the table List.Price. (Only the Address column appears in both tables.)
proc sql;
   _____________
       from list.size,list.price;
a. select address,sqfeet,price
b. select size.address,sqfeet,price  
c. select price.address,sqfeet,price
d. either b or c  

我觉得答案应该是D,怎么会是B呀。不理解。
作者: shiyiming    时间: 2010-5-30 10:39
标题: Re: SAS SQL 高手请进
要是不相信
你选择C
然后吧
SIZE 和LIST交换一下前后位置
作者: shiyiming    时间: 2010-5-30 10:48
标题: Re: SAS SQL 高手请进
base online tutorial的正解:
[quote:1xbdhv2d]The SELECT clause lists the columns from both tables to be queried. You must use a prefix with the Address column because it appears in both tables. The prefix specifies the table from which you want the column to be read.  [/quote:1xbdhv2d]
我的胡说:
如果sql有where子句(where size.address=price.address;)的话,c应该也可以,因为这是个inner join嘛; 但现在就一from语句,查询的结果将是个笛卡儿乘积,size.address和price.address不一定相等呀
[code:1xbdhv2d]data a;
        input id x $;
datalines;
1 a
2 d
;
data b;
        input id y $;
datalines;
1 c
2 d
3 e
;
proc sql;
        select * from a,b;
quit;[/code:1xbdhv2d]




欢迎光临 SAS中文论坛 (http://www.mysas.net/forum/) Powered by Discuz! X3.2