日期:2014-05-18 浏览次数:20390 次
From table1 pl, table2 pe, table3 ch, table4 cp Where (pe.dt >= @dt and pe.dt <= @dt_end ) and (cp.name = ‘source' and pe.s *= cp.s) and (ch.name = 'status' and pe.hr_status_cd *= ch.code)' --=========================================================== from table1 pl inner join Table2 pe on --??? 这个地方,应该有跟pl的连接关系 left join table3 ch on pe.hr_status_cd = ch.code left join table4 cp on pe.s = cp.s where ch.name ='status' and cp.name ='source' and pe.dt >=@dt and pe.dt <=@dt_end
------解决方案--------------------
from table1 pl inner join Table2 pe on 1=1 --没有明确关系,可以用1=1代替 left join table3 ch on pe.hr_status_cd = ch.code left join table4 cp on pe.s = cp.s where ch.name ='status' and cp.name ='source' and pe.dt >=@dt and pe.dt <=@dt_end