使用新的内部查询sql加入结果

时间:2015-05-12 17:23:12

标签: oracle

select A.UNIT, A.LEASE_ID, A.MONTHS_GUARANTEED, A.MONTHLY_PAYMENT_AM, 
B.DATE_PAID, C.CHARGE_JOB from leasei A 
left outer join eq_capture B on A.LEASE_ID = B.LEASE_ID 
left outer join eq_mast C on A.UNIT = C.UNIT
where A.DATE_LEASE_EXPIRE = 0
ORDER BY A.LEASE_ID;

我想使用上面查询的结果,使用值C.CHARGE_JOB并检查另一个表(job_infojc D)并获取带有where条件的D.STATE值C.CHARGE_JOB = D.JOB < / p>

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:2)

像这样:

select D.STATE, X.*
from job_infojc D
join (select A.UNIT, A.LEASE_ID, A.MONTHS_GUARANTEED, A.MONTHLY_PAYMENT_AM, 
B.DATE_PAID, C.CHARGE_JOB from leasei A 
left outer join eq_capture B on A.LEASE_ID = B.LEASE_ID 
left outer join eq_mast C on A.UNIT = C.UNIT
where A.DATE_LEASE_EXPIRE = 0
) X on X.CHARGE_JOB = D.JOB
ORDER BY X.LEASE_ID;