• Post category:BI Publisher
  • Post comments:1 Comment
  • Post last modified:June 12, 2020
  • Reading time:1 min read
You are currently viewing How to get Position Hierarchy in SQL Query?
How to get Position Hierarchy in SQL Query?

We can use the below query to get the Position Hierarchy of a Position traversing up to the top level.

SQL Query:

SELECT hap.POSITION_CODE
 ,hap.position_id
 ,hap.name
 ,(SELECT name
  FROM HR_ALL_POSITIONS
  WHERE POSITION_ID = pphf.PARENT_POSITION_ID
  ) Parent_Position_NAME
 ,decode(hap.ACTIVE_STATUS, 'A', 'Active', 'I', 'Inactive') ACTIVE_Status
 ,pj.manager_level
 ,pj.name
FROM HR_ALL_POSITIONS hap
 ,PER_JOBS_F_VL PJ
 ,PER_POSITION_HIERARCHY_F pphf
WHERE hap.POSITION_ID = pphf.POSITION_ID
 AND hap.job_id = pj.job_id
 AND sysdate BETWEEN pphf.effective_start_date
  AND pphf.effective_end_date START
WITH pphf.position_id = :INPUT_POSITION_ID CONNECT BY PRIOR pphf.PARENT_POSITION_ID = pphf.POSITION_ID 

If you have any questions, please feel free to reach out to me by posting in comments section.

If you are interested in learning Fusion Technical tools go through this post

If you liked the article, please share it with your friends/ colleagues/ teammates or anyone who might also benefit from it.

This Post Has One Comment

  1. Emma

    Hi there ,

    Is it possible to tell me how to create an sql to extract the position hierarchy levels up to 7 levels and to appear like level 1 the higher level 7 the lowest. But keep in mind that level 1 can have a lot level 2 positions etc. Can you help me ?

  2. In visible box by plugintheme

Leave a Reply