[英]left outer join in oracle issues
In this query below, I need left outer join to work so that resulting dataset contains all the values of a.terr_num that match and unmatch with b.terr_num 在下面的此查询中,我需要左外部连接才能起作用,以便所得数据集包含与b.terr_num匹配和不匹配的a.terr_num的所有值。
somehow this is not working.. please help 无论如何这是行不通的..请帮助
select b.sales_regn, b.sales_area, b.terr_num, a.terr_num, a.terr_name
from kp_terr_region b
left outer join kap_terr a on a.terr_num = b.terr_num
where a.valid_to > sysdate
and a.ptr_type = 'JPN'
and a.status != 1
and a.valid_to > sysdate
and b.valid_to > sysdate
and a.slr_num is null;
If I'm understanding your question correctly, you are negating your outer join
with the where
criteria. 如果我正确理解了您的问题,则说明您在使用
where
条件否定outer join
联接。 Move that criteria to the join
instead: 此举标准的
join
,而不是:
select b.sales_regn, b.sales_area, b.terr_num, a.terr_num, a.terr_name
from kp_terr_region b
left outer join kap_terr a on a.terr_num = b.terr_num
and a.valid_to > sysdate
and a.ptr_type = 'JPN'
and a.status != 1
and a.slr_num is null
where b.valid_to > sysdate
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.