Pages

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

1 comment:

  1. Mastering database architecture, complex SQL queries, and PL/SQL blocks can get incredibly intense, especially when you are trying to configure database instances and ensure relational integrity all at the same time. When the pressure of university deadlines starts building up alongside tricky compiler errors, finding reliable Oracle Assignment Help in UK services is a complete game-changer. Partnering with experienced coding experts who understand both database optimization and strict UK academic grading criteria is easily the smartest way to keep your technical documentation organized, reduce debugging stress, and secure top marks. Thanks for sharing this helpful post!

    ReplyDelete