SELECT papf.person_number
,TO_CHAR (pps.date_start
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
person_hire_date
,TO_CHAR (pps.actual_termination_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
person_termination_date
,TO_CHAR (paaf.effective_start_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
assignment_start_date
,TO_CHAR (paaf.effective_end_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
assignment_end_date
,TO_CHAR (pasf.effective_start_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_start_date
,TO_CHAR (pasf.effective_end_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_end_date
,pasf.manager_type
,pasf.primary_flag
,paaf.assignment_number
,papfs.person_number manager_number
,TO_CHAR (ppss.date_start
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_hire_date
,TO_CHAR (ppss.actual_termination_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_termination_date
FROM per_periods_of_service ppss
,per_all_people_f papfs
,per_assignment_supervisors_f pasf
,per_all_people_f papf
,per_all_assignments_m paaf
,per_periods_of_service pps
WHERE ppss.person_id(+) = papfs.person_id
AND pasf.effective_start_date BETWEEN papfs.effective_start_date(+) AND papfs.effective_end_date(+)
AND papfs.person_id(+) = pasf.manager_id
AND paaf.effective_start_date BETWEEN pasf.effective_start_date(+) AND pasf.effective_end_date(+)
AND pasf.assignment_id(+) = paaf.assignment_id
AND papf.person_number = NVL (:p_person_number, papf.person_number)
AND pps.date_start BETWEEN papf.effective_start_date AND papf.effective_end_date
AND papf.person_id = paaf.person_id
AND paaf.effective_latest_change = 'Y'
AND paaf.primary_assignment_flag = 'Y'
AND paaf.primary_flag = 'Y'
AND paaf.assignment_type = 'E'
AND paaf.period_of_service_id = pps.period_of_service_id
ORDER BY papf.person_number
,paaf.effective_start_date
,TO_CHAR (pps.date_start
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
person_hire_date
,TO_CHAR (pps.actual_termination_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
person_termination_date
,TO_CHAR (paaf.effective_start_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
assignment_start_date
,TO_CHAR (paaf.effective_end_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
assignment_end_date
,TO_CHAR (pasf.effective_start_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_start_date
,TO_CHAR (pasf.effective_end_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_end_date
,pasf.manager_type
,pasf.primary_flag
,paaf.assignment_number
,papfs.person_number manager_number
,TO_CHAR (ppss.date_start
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_hire_date
,TO_CHAR (ppss.actual_termination_date
,'DD-Mon-YYYY'
,'NLS_DATE_LANGUAGE=AMERICAN')
manager_termination_date
FROM per_periods_of_service ppss
,per_all_people_f papfs
,per_assignment_supervisors_f pasf
,per_all_people_f papf
,per_all_assignments_m paaf
,per_periods_of_service pps
WHERE ppss.person_id(+) = papfs.person_id
AND pasf.effective_start_date BETWEEN papfs.effective_start_date(+) AND papfs.effective_end_date(+)
AND papfs.person_id(+) = pasf.manager_id
AND paaf.effective_start_date BETWEEN pasf.effective_start_date(+) AND pasf.effective_end_date(+)
AND pasf.assignment_id(+) = paaf.assignment_id
AND papf.person_number = NVL (:p_person_number, papf.person_number)
AND pps.date_start BETWEEN papf.effective_start_date AND papf.effective_end_date
AND papf.person_id = paaf.person_id
AND paaf.effective_latest_change = 'Y'
AND paaf.primary_assignment_flag = 'Y'
AND paaf.primary_flag = 'Y'
AND paaf.assignment_type = 'E'
AND paaf.period_of_service_id = pps.period_of_service_id
ORDER BY papf.person_number
,paaf.effective_start_date