不积跬步,无以至千里

博客园 首页 新随笔 联系 订阅 管理

with t as
(select 'a'c1,'b'c2,'c'c3 from dual union
select 'a','b','d' from dual union
select 'a','e','f' from dual),
t1 as
(select c1,c2 from t
union
select c2,c3 from t),
t2 as
(select c1 from t1
union
select c2 from t1),
t3 as
(select c1,rownum rn from(select c1 from t2 order by c1)),
t4 as
(select a.*,b.c1 p from t3 a left join t1 b on(a.c1=b.c2))
select x.c1,x.rn,nvl(y.rn,0)prn from t4 x left join t3 y on(x.p=y.c1) order by 1;

posted on 2016-09-08 16:12  Zeroassetsor  阅读(261)  评论(0)    收藏  举报