SAS中文论坛

标题: 为什么需要Reflexive Join [打印本页]

作者: shiyiming    时间: 2011-1-9 14:49
标题: 为什么需要Reflexive Join
例题(来自adv prep guide):
Suppose you want to list the names of supervisors for the crew on the flight to Copenhagen on March 4, 2000.

sasuser.flightschedule (empid, date, destination)
sasuser.staffmaster (empid, firstname, lastname, state)
sasuser.payrollmaster (empid, jobcode)
sasuser.supervisors(empid, state, jobcategory)

proc sql;
  select distinct e.firstname, e.lastname
    from sasuser.flightschedule as a,
            sasuser.staffmaster    as b,
            sasuser.payrollmaster  as c,
            sasuser.supervisors     as d,
            sasuser.staffmaster     as e
    where a.date='04mar2000'd and
              a.destination='cph'   and
              a.empid=b.empid and
              a.empid=c.empid and
              d.jobcategory=substr(c.jobcode,1,2)
              and d.state=b.state
              and d.empid=e.empid;
quit;

我的问题是:为什么list sasuser.staffmaster 两次,有必要吗?




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