項目樹型結構顯示的SQL語句--記錄

SELECT a.org_id, a.org_name
  FROM org a
 WHERE a.org_parentid = 1
   AND ((a.org_id in
       (select org_id
            from user_org
           where user_id in (select user_.user_id
                               from user_, user_role, wf_step_role
                              where wf_step_role.role_id = user_role.role_id
                                and user_role.user_id = user_.user_id
                                and wf_step_role.step_id = 2))) OR
       (SELECT COUNT(*)
           FROM org b
          WHERE b.org_id in
                (select org_id
                   from user_org
                  where user_id in
                        (select user_.user_id
                           from user_, user_role, wf_step_role
                          where wf_step_role.role_id = user_role.role_id
                            and user_role.user_id = user_.user_id
                            and wf_step_role.step_id = 2))
            and rownum < 2
          START WITH b.org_id = a.org_id
         CONNECT BY PRIOR b.org_id = b.org_parentid) > 0)
 order by org_order

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章