oracle start with connect by使用

select
   count(*),
   root
from
(
  select dep.dep_id,dep.dep_parent,connect_by_root(dep.dep_id) root,connect_by_root(dep.name_mix) rootName from police_command_ds_dep dep
  start with dep.dep_parent = '1'
  connect by prior dep.dep_id = dep.dep_parent
) group by root

 

 

Select * From POLICE_COMMAND_DS_DEP
Start With dep_id = '1'
Connect By nocycle Prior dep_id = dep_parent

说明:nocycle 避免一条数据的 dep_id = 1 dep_parent=1导致死循环

你可能感兴趣的:(oracle,start,with,connect,by使用,数据库)