Pages

Thursday, January 1, 2015

Query to Display Organization Hierarchy





SQL Query To  Display Organization Hierarchy


/* Formatted on 1/1/2015 4:18:35 PM (QP5 v5.215.12089.38647) */

 SELECT LPAD (' ', 10 * (LEVEL - 1)) || org.name hierarchy,
           org.organization_id
      FROM hr_all_organization_units org, per_org_structure_elements pose
     WHERE     1 = 1
           AND org.organization_id = pose.organization_id_child
           AND pose.org_structure_version_id = 62
START WITH pose.organization_id_parent = 44 -- Orgnization of parent id -- provide the id from which level the downward hierarchy should be displaed
CONNECT BY PRIOR pose.organization_id_child = pose.organization_id_parent

1 comment:

  1. Can you please also help ,if only 2 level of hierarchy is required .

    ReplyDelete