Social Icons

Monday, January 1, 2018

Employee assignment movement details query

/* Formatted on 12/31/2017 12:21:01 PM (QP5 v5.294) */
  SELECT ppf.employee_number,
         paaf.assignment_number,
         ppf.full_name,
         paaf.organization_id         current_org_id,
         paaf.effective_start_date    Curr_org_start_date,
         (SELECT name
            FROM hr_all_organization_units
           WHERE organization_id = paaf.organization_id)
            current_org_name,
         paaf_prev.effective_start_date prev_org_start_date,
         paaf_prev.organization_id    prev_org_id,
         (SELECT name
            FROM hr_all_organization_units
           WHERE organization_id = paaf_prev.organization_id)
            prev_org,
            (SELECT name
            FROM PER_POSITIONS
           WHERE POSITION_ID = paaf.POSITION_ID) CURRENT_POSITION,
           (SELECT name
            FROM PER_GRADES
           WHERE GRADE_ID = paaf.GRADE_ID) CURRENT_GRADE,
(SELECT name
            FROM PER_GRADES
           WHERE GRADE_ID = paaf_prev.GRADE_ID) PREVIOUS_GRADE  ,
(SELECT name
            FROM PER_POSITIONS
           WHERE POSITION_ID = paaf_prev.POSITION_ID) PREVIOUS_POSITION     ,
         hr_general.decode_lookup ('EMP_ASSIGN_REASON', PAAF.change_reason)
            MOVE_TYPE
    FROM per_all_assignments_f paaf,
         per_all_assignments_f paaf_prev,
         pay_people_groups   ppg,
         pay_people_groups   ppg_prev,
         per_all_people_f    ppf
   WHERE     paaf_prev.effective_end_date + 1 = paaf.effective_start_date
         AND paaf_prev.assignment_id = paaf.assignment_id
         AND paaf_prev.assignment_type = 'E'
         --and ppf.employee_number = '1134'
         AND paaf.assignment_type = 'E'
         AND paaf.organization_id <> paaf_prev.organization_id
         AND paaf.PEOPLE_GROUP_ID = ppg.people_group_id
         AND paaf_prev.PEOPLE_GROUP_ID = ppg_prev.people_group_id
         AND ppf.BUSINESS_GROUP_ID = 81
         AND paaf.effective_start_date BETWEEN ppf.effective_start_date
                                           AND ppf.effective_end_date
         AND paaf.person_id = ppf.person_id 
        -- AND    paaf_prev.effective_start_date >= :p_effective_date 
ORDER BY paaf_prev.effective_start_date DESC

No comments :

Post a Comment

">