|
|
C1,C2,C3的格式有点不一样,还可以这样
SQL>
SQL> select pid,id,level lvl,
2 connect_by_root(id) root,
3 prior pid c1,
4 pid c2,
5 id c3
6 from test t
7 connect by prior t.id = t.pid
8 start with t.pid is null
9 /
PID ID LVL ROOT C1 C2 C3
-------------------- -------------------- ---------- -------------------- -------------------- -------------------- --------------------
中国 1 中国 中国
中国 广东 2 中国 中国 广东
广东 深圳 3 中国 中国 广东 深圳
深圳 福田 4 中国 广东 深圳 福田
中国 广西 2 中国 中国 广西 |
|