SELECT PAPF.person_number
,PPNF.full_name
,To_char(PPOS_MAIN.date_start, 'DD-MON-YYYY', 'nls_date_language=American') hire_date
,dept.NAME dept_name
,pos.NAME pos_name
,HRL.NAME LE_NAME
,hc.value HEADCOUNT
,To_char(PAAF.effective_start_date, 'DD-MON-YYYY', 'nls_date_language=American') effective_start_date
,To_char(PAAF.effective_end_date, 'DD-MON-YYYY', 'nls_date_language=American') effective_end_date
,To_char(PPOS_MAIN.actual_termination_date, 'DD-MON-YYYY', 'nls_date_language=American') termination_date
,pastvl.user_status assignment_status
FROM per_all_people_f PAPF
,per_person_names_f PPNF
,per_all_assignments_f PAAF
,per_periods_of_service PPOS_MAIN
,pay_payroll_assignments PPASG
,per_assignment_status_types_vl pastvl
,per_legal_employers HRL
,HR_ALL_ORGANIZATION_UNITS_F_VL dept
,HR_ALL_POSITIONS_F_VL pos
,PER_ASSIGN_WORK_MEASURES_F_V hc
WHERE PAPF.person_id = PPNF.person_id
AND PPNF.name_type = 'GLOBAL'
AND PPOS_MAIN.date_start = (
SELECT Max(date_start)
FROM per_periods_of_service PPOS
WHERE PPOS.person_id = PAPF.person_id
)
AND PPOS_MAIN.person_id = PAPF.person_id
AND PAAF.person_id = PAPF.person_id
AND PAAF.assignment_type IN ('E')
AND PPOS_MAIN.period_of_service_id = PAAF.period_of_service_id
AND PAAF.assignment_id = PPASG.hr_assignment_id
AND PAAF.legal_entity_id = HRL.organization_id
AND HRL.STATUS = 'A'
AND paaf.organization_id = dept.organization_id
AND paaf.position_id = pos.position_id(+)
AND paaf.assignment_id = hc.assignment_id(+)
AND hc.UNIT(+) = 'HEAD'
AND Nvl(PPOS_MAIN.actual_termination_date, Trunc(SYSDATE)) BETWEEN PPASG.start_date
AND PPASG.end_date
AND PAAF.assignment_status_type_id = PASTVL.assignment_status_type_id --AND PAAF.ASSIGNMENT_STATUS_TYPE <> 'INACTIVE'
AND Trunc(SYSDATE) BETWEEN PAPF.effective_start_date
AND PAPF.effective_end_date
AND Trunc(SYSDATE) BETWEEN PPNF.effective_start_date
AND PPNF.effective_end_date
AND Trunc(SYSDATE) BETWEEN PAAF.effective_start_date
AND PAAF.effective_end_date
AND Trunc(SYSDATE) BETWEEN HRL.effective_start_date
AND HRL.effective_end_date
AND Trunc(SYSDATE) BETWEEN dept.effective_start_date
AND dept.effective_end_date
AND Trunc(SYSDATE) BETWEEN pos.effective_start_date(+)
AND pos.effective_end_date(+)
AND Trunc(SYSDATE) BETWEEN hc.effective_start_date(+)
AND hc.effective_end_date(+)
AND PAPF.person_number IN ('12345')
x
,PPNF.full_name
,To_char(PPOS_MAIN.date_start, 'DD-MON-YYYY', 'nls_date_language=American') hire_date
,dept.NAME dept_name
,pos.NAME pos_name
,HRL.NAME LE_NAME
,hc.value HEADCOUNT
,To_char(PAAF.effective_start_date, 'DD-MON-YYYY', 'nls_date_language=American') effective_start_date
,To_char(PAAF.effective_end_date, 'DD-MON-YYYY', 'nls_date_language=American') effective_end_date
,To_char(PPOS_MAIN.actual_termination_date, 'DD-MON-YYYY', 'nls_date_language=American') termination_date
,pastvl.user_status assignment_status
FROM per_all_people_f PAPF
,per_person_names_f PPNF
,per_all_assignments_f PAAF
,per_periods_of_service PPOS_MAIN
,pay_payroll_assignments PPASG
,per_assignment_status_types_vl pastvl
,per_legal_employers HRL
,HR_ALL_ORGANIZATION_UNITS_F_VL dept
,HR_ALL_POSITIONS_F_VL pos
,PER_ASSIGN_WORK_MEASURES_F_V hc
WHERE PAPF.person_id = PPNF.person_id
AND PPNF.name_type = 'GLOBAL'
AND PPOS_MAIN.date_start = (
SELECT Max(date_start)
FROM per_periods_of_service PPOS
WHERE PPOS.person_id = PAPF.person_id
)
AND PPOS_MAIN.person_id = PAPF.person_id
AND PAAF.person_id = PAPF.person_id
AND PAAF.assignment_type IN ('E')
AND PPOS_MAIN.period_of_service_id = PAAF.period_of_service_id
AND PAAF.assignment_id = PPASG.hr_assignment_id
AND PAAF.legal_entity_id = HRL.organization_id
AND HRL.STATUS = 'A'
AND paaf.organization_id = dept.organization_id
AND paaf.position_id = pos.position_id(+)
AND paaf.assignment_id = hc.assignment_id(+)
AND hc.UNIT(+) = 'HEAD'
AND Nvl(PPOS_MAIN.actual_termination_date, Trunc(SYSDATE)) BETWEEN PPASG.start_date
AND PPASG.end_date
AND PAAF.assignment_status_type_id = PASTVL.assignment_status_type_id --AND PAAF.ASSIGNMENT_STATUS_TYPE <> 'INACTIVE'
AND Trunc(SYSDATE) BETWEEN PAPF.effective_start_date
AND PAPF.effective_end_date
AND Trunc(SYSDATE) BETWEEN PPNF.effective_start_date
AND PPNF.effective_end_date
AND Trunc(SYSDATE) BETWEEN PAAF.effective_start_date
AND PAAF.effective_end_date
AND Trunc(SYSDATE) BETWEEN HRL.effective_start_date
AND HRL.effective_end_date
AND Trunc(SYSDATE) BETWEEN dept.effective_start_date
AND dept.effective_end_date
AND Trunc(SYSDATE) BETWEEN pos.effective_start_date(+)
AND pos.effective_end_date(+)
AND Trunc(SYSDATE) BETWEEN hc.effective_start_date(+)
AND hc.effective_end_date(+)
AND PAPF.person_number IN ('12345')
x
No comments:
Post a Comment