3,491
社区成员
发帖
与我相关
我的任务
分享
with tmp as
(
select '001' c1, '天津公司' c2, null c3 from dual union all
select '002' c1, '北京公司' c2, null c3 from dual union all
select '00101' c1, '天津滨海区公司' c2, '001' c3 from dual union all
select '00201' c1, '北京故宫公司' c2, '002' c3 from dual
)
select t1.c1 "客户编码",t1.c2 "客户名称 ",t2.c2 "上级客户名称"
from tmp t1
left join tmp t2 on t1.c3= t2.c1