【sas proc sql】子查询
1 proc sql feedback; 2 select * from merge_a 3 where flight>(select max(flight) from merge_b); 4 quit;
1 proc sql feedback; 2 select * from merge_a 3 where flight in (select flight from merge_b); 4 quit;
-----correlated subquery
1 proc sql feedback; 2 select * from merge_a a 3 where flight=(select flight from merge_b where mergeb.flight=a.flight); 4 quit;
correlated subquery会把每一次匹配的外部值传回子查询中,子查询匹配后返回select值。
If subquery returnes a single result then "=" is acceptable ,otherwise you have to use in union any or all operator.
1 proc sql feedback; 2 select * from merge_a a 3 where exists (select flight from merge_b where merge_b.flight=a.flight); 4 quit;
exists和correlated subquery 起类似的作用。
子查询可以重复嵌套。