17,378
社区成员
发帖
与我相关
我的任务
分享
with part as
(select 'P1' as PART,'S1' as SUPP1,'S2' as SUPP2,'S3' as SUPP3 from dual
union all
select 'P2' as PART,'S2' as SUPP1,'S3' as SUPP2, null as SUPP3 from dual
union all
select 'P3' as PART,'S1' as SUPP1,'S3' as SUPP2, null as SUPP3 from dual
union all
select 'P4' as PART,'S1' as SUPP1,null as SUPP2,null as SUPP3 from dual)
,
supplier as
(select 'S1' as SUPP, 'Supplier#1' AS SUPPLIER_NAME from dual
UNION ALL
select 'S2' as SUPP, 'Supplier#2' AS SUPPLIER_NAME from dual
union all
select 'S3' as SUPP, 'Supplier#3' AS SUPPLIER_NAME from dual
)
select part,
(select SUPPLIER_NAME from supplier where supp = t.supp1) as supp1,
(select SUPPLIER_NAME from supplier where supp = t.supp2) as supp2,
(select SUPPLIER_NAME from supplier where supp = t.supp3) as supp3
from part t
select part,
(select SUPPLIER_NAME from supplier where supp = t.supp1) as supp1,
(select SUPPLIER_NAME from supplier where supp = t.supp2) as supp2,
(select SUPPLIER_NAME from supplier where supp = t.supp3) as supp3
from part t