[英]left outer join in oracle issues
在下面的此查詢中,我需要左外部連接才能起作用,以便所得數據集包含與b.terr_num匹配和不匹配的a.terr_num的所有值。
無論如何這是行不通的..請幫助
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;
如果我正確理解了您的問題,則說明您在使用where
條件否定outer join
聯接。 此舉標准的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.