Query to fetch Past Position Incumbents Details in Fusion HCM

SELECT position_code,
       hap.name               position_name,
       hl.location_name,
       pd.name                organization_name,
       hou.name               business_unit_name,
       paam.assignment_number Past_Incumbents,
       pg.name                Past_Incumbents_Grade,
       cmp.salary_amount
FROM   hr_all_positions hap,
       hr_locations_all_f_vl hl,
       per_departments pd,
       hr_organization_units hou,
       per_grades pg,
       cmp_salary cmp,
       per_all_assignments_m paam
WHERE  1 = 1
       -- position_code ='60063452'
       AND hap.active_status = 'A'
       AND TRUNC(SYSDATE) BETWEEN hap.effective_start_date AND
                                  hap.effective_end_date
       ---------------------- Location ----------------------------------------
       AND hap.location_id = hl.location_id
       AND TRUNC(SYSDATE) BETWEEN hl.effective_start_date AND
                                  hl.effective_end_date
       AND hl.active_status = 'A'
       ---------------------------------------- --dept ----------------------------------------
       AND hap.organization_id = pd.organization_id(+)
       AND TRUNC(SYSDATE) BETWEEN pd.effective_start_date AND
                                  pd.effective_end_date
       AND pd.status = 'A'
       --------------------------- --bu ----------------------------------------
       AND hap.business_unit_id = hou.organization_id(+)
       ---------------------------------------- Assignment ----------------------------------------
       AND hap.position_id = paam.position_id
       AND TRUNC(SYSDATE) NOT BETWEEN paam.effective_start_date AND
                                      paam.effective_end_date
       AND paam.assignment_status_type IN ( 'ACTIVE' ) -- Active Assignment
       AND paam.assignment_type IN ( 'E' ) -- Type Employee
       AND paam.primary_flag = 'Y' -- primary assignment
       --------------------------------------GRADE------------------------------------
       AND paam.grade_id = pg.grade_id
       AND TRUNC(SYSDATE) BETWEEN pg.effective_start_date AND
                                  pg.effective_end_date
       AND pg.active_status = 'A'
       --------------------------------------SALARY------------------------------------
       AND paam.assignment_id = cmp.assignment_id(+)
       AND paam.effective_start_date BETWEEN cmp.date_from(+) AND cmp.date_to(+) 

No comments:

Post a Comment