select a.client_department_id,
a.parent_id,
level "层次",
sys_connect_by_path(client_department_id, '->') "合并层次",
prior a.client_department_id "父节点",
connect_by_root a.client_department_id "根节点",
decode(connect_by_isleaf, 1, a.client_department_id, null) "子节点",
decode(connect_by_isleaf, 1, '是', '否') "是否子节点"
from client.client_department a
--where client_department_id=103
start with parent_id=100
connect by prior client_department_id=parent_id[@more@]
a.parent_id,
level "层次",
sys_connect_by_path(client_department_id, '->') "合并层次",
prior a.client_department_id "父节点",
connect_by_root a.client_department_id "根节点",
decode(connect_by_isleaf, 1, a.client_department_id, null) "子节点",
decode(connect_by_isleaf, 1, '是', '否') "是否子节点"
from client.client_department a
--where client_department_id=103
start with parent_id=100
connect by prior client_department_id=parent_id[@more@]
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/41451/viewspace-1059835/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/41451/viewspace-1059835/