yangqin4587 发表于 2016-1-16 10:19
一道新题
left join and in-line view
Product
15 Proc sql;
16 Select p.product, s.totalsales
17 From product as p
18 left join (select sum(sales) as totalsales from sales as s)
19 on p.product_id=s.product_id;
ERROR: Column totalsales could not be found in the table/view identified with the correlation name S.
NOTE: PROC SQL set option NOEXEC and will continue to check the syntax of statements.
if i remove the s. from s.totalsale,
15 Proc sql;
16 Select p.product, totalsales
17 From product as p
18 left join (select sum(sales) as totalsales from sales as s)
19 on p.product_id=s.product_id;
NOTE: The query requires remerging summary statistics back with the original data.
and output is :
product totalsales
1001 800
1001 800
1001 800
1002 .
1003 800
1003 800
any ideas?