SELECT ppf.employee_number,
paaf.assignment_number,
ppf.full_name,
paaf.organization_id current_org_id,
paaf.effective_start_date current_org_start_date,
(SELECT name
FROM hr_all_organization_units
WHERE organization_id = paaf.organization_id)
current_org_name,
paaf_previous.effective_start_date previous_org_start_date,
paaf_previous.organization_id previous_org_id,
(SELECT name
FROM hr_all_organization_units
WHERE organization_id = paaf_previous.organization_id)
previous_org_name
FROM per_all_assignments_f paaf,
per_all_assignments_f paaf_previous,
pay_people_groups ppg,
pay_people_groups ppg_previous,
per_all_people_f ppf
WHERE paaf_previous.effective_end_date + 1 = paaf.effective_start_date
AND paaf_previous.assignment_id = paaf.assignment_id
AND paaf_previous.assignment_type = 'E'
AND paaf.assignment_type = 'E'
AND paaf.organization_id <> paaf_previous.organization_id
AND paaf.PEOPLE_GROUP_ID = ppg.people_group_id
AND paaf_previous.PEOPLE_GROUP_ID = ppg_previous.people_group_id
AND paaf.effective_start_date BETWEEN ppf.effective_start_date
AND ppf.effective_end_date
AND paaf.person_id = ppf.person_id
AND ppf.employee_number = '1234567890'
ORDER BY paaf_previous.effective_start_date DESC
No comments:
Post a Comment