SQL Query to Fetch Employees
SELECT papf.person_number, hauft.name businessunit
FROM hr_org_unit_classifications_f houcf,
hr_all_organization_units_f haouf,
hr_organization_units_f_tl hauft,
per_all_assignments_m paam,
per_all_people_f papf
WHERE haouf.organization_id = houcf.organization_id
AND haouf.organization_id = hauft.organization_id
AND haouf.effective_start_date BETWEEN houcf.effective_start_date
AND houcf.effective_end_date
AND hauft.language = 'US'
AND hauft.effective_start_date = haouf.effective_start_date
AND hauft.effective_end_date = haouf.effective_end_date
AND SYSDATE BETWEEN hauft.effective_start_date
AND hauft.effective_end_date
AND hauft.organization_id = paam.business_unit_id
AND paam.person_id = papf.person_id
AND paam.assignment_type = 'E'
AND paam.effective_latest_change = 'Y'
AND SYSDATE BETWEEN paam.effective_start_date
AND paam.effective_end_date
AND papf.person_number = NVL (:personnumber, papf.person_number)