有这样一道题,我的问题请看proc sql中的comment:
两个data sets
Product
Product_id Product
1 1001
2 1002
3 1003
Sales
Product_id Sales
3 100
1 200
5 100
1 200
3 100
1 100
Proc sql;
Select p.product, s.totalsales
From product as p
left join (
select sum(sales) as totalsales
from sales as s)
/*
This in-line view should be
(select sum(sales) as Totalsales
from sales as s
where p.product_id = s.product_id)
不是吗?
如果没有这句where clause,这个in-line view不是指返回一个sum(sales)的结果吗?还是说left join 是直接根据外部on的条件逐条pass到这个in-line view里的然后生成一个sum for each pass?
*/
on p.product_id=s.product_id;
quit;
What is the output?
Answer:
Product Totalsales
1001 500
1002 .
1003 200