The below query can be used to get the Organizations which belongs to a hierarchy which is defined in the Organization Hierarchy.
Thanks to Sajeer Omar.
Replace the below hardcoded values before executing :
Business group ID
Organization Hierarchy Name
Top Organization Name
If you want to get only the organization as a specific level, uncomment the commented whereclause.
select(lpad(' ', (lvl -1) *5,' ') || haou_c.name) org_name ,org_hier.*fromhr_all_organization_units haou_c ,(selecthier.organization_id_parent ,hier.organization_id_child ,levellvl ,sys_connect_by_path(hier.organization_id_child,'/') org_level ,sys_connect_by_path(level,'/') hier_levelfromper_org_structure_elements hier ,(selectvers.org_structure_version_idfromper_organization_structures_v struct ,per_org_structure_versions_v verswherestruct.business_group_id =0-- Business group IDandstruct.name ='AJ Hierarchy'-- Organization Hierarchy Nameandstruct.organization_structure_id = vers.organization_structure_idandstruct.business_group_id = vers.business_group_idandSYSDATE BETWEEN vers.date_from and nvl(vers.date_to, sysdate)andrownum=1) orgstrwherehier.org_structure_version_id = orgstr.org_structure_version_idandhier.business_group_id =0-- Business group IDstartwithhier.organization_id_parent = (selecta.organization_idfromhr_all_organization_units awherea.name ='AJ Pty Ltd (Australia)')-- Top Organization Nameandhier.org_structure_version_id = orgstr.org_structure_version_idandhier.business_group_id = 0-- Business group IDconnectbypriororganization_id_child = organization_id_parent) org_hierwherehaou_c.organization_id = org_hier.organization_id_child--and org_hier.lvl = 2 -- If you want to get only a specific level valuesorderbyorg_hier.org_level;
Feel free to point out if anything is missing/wrong in this blog.
Thank you.
ReplyDelete