我有两个问题。
select a.supplier_nbr
from co_global_duns_xref_t a,
co_global_duns_t b
where
a.global_duns_nbr=b.global_duns_nbr(+)
和
select supplier_name_txt
from (
select supplier_nbr,supplier_name_txt, source_system_id,
row_number() over (order by source_system_id) precedence_nbr
from er_supplier_t
where source_system_id in (
SELECT source_system_id
FROM co_source_system_t
where active_flag = 'Y' and
erp_version_cd = '3.1'
) and
-- supplier_nbr = '211394790'
)
where precedence_nbr = 1
从第一个查询我将获得供应商nbr。对于该供应商,我需要在第二个中搜索供应商名称并显示两者。 请告诉我该怎么做?
答案 0 :(得分:0)
select supplier_name_txt
from (
select supplier_nbr,supplier_name_txt, source_system_id,
row_number() over (order by source_system_id) precedence_nbr
from er_supplier_t
where source_system_id in (
SELECT source_system_id
FROM co_source_system_t
where active_flag = 'Y' and
erp_version_cd = '3.1'
) and
supplier_nbr = '211394790' ---
) a join co_global_duns_xref_t b on a.supplier_nbr = b.supplier_nbr
where precedence_nbr = 1
答案 1 :(得分:0)
我仍然对这个问题感到有些困惑,但我会接受回答。您应该能够将第一个查询放在第二个查询中,然后按供应商编号加入。
SELECT supplier_nbr,
supplier_name_txt
FROM (SELECT er.supplier_nbr,
supplier_name_txt,
source_system_id,
row_number() over (PARTITION BY er.supplier_nbr ORDER BY source_system_id) precedence_nbr
FROM er_supplier_t er,
(SELECT a.supplier_nbr
FROM co_global_duns_xref_t a,
co_global_duns_t b
WHERE a.global_duns_nbr=b.global_duns_nbr(+)
) a
WHERE source_system_id IN (SELECT source_system_id
FROM co_source_system_t
WHERE active_flag = 'Y'
AND erp_version_cd = '3.1'
)
AND er.supplier_nbr = a.supplier_nbr
)
WHERE precedence_nbr = 1
我还必须通过supplier_nbr
将row_number分析函数更改为分区