Query to fetch Business Unit Name of Employee
select papf.person_number,
papf.person_id,
papf.start_date,
ppnf.full_name employee_full_name,
paam.assignment_number,
hou.name business_unit_name
from per_all_people_f papf,
per_all_assignments_m paam,
per_person_names_f ppnf,
hr_organization_units hou
where 1 = 1
and trunc(sysdate) between papf.effective_start_date and
papf.effective_end_date
and papf.person_id = ppnf.person_id
and trunc(sysdate) between ppnf.effective_start_date and
ppnf.effective_end_date
and ppnf.name_type = 'GLOBAL'
and papf.person_id = paam.person_id
and trunc(sysdate) between paam.effective_start_date and
paam.effective_end_date
and paam.assignment_status_type in ( 'ACTIVE' ) -- Active Assignment
and paam.assignment_type in ( 'E' ) -- Type Employee
and paam.primary_flag = 'Y' -- primary assignment
and paam.business_unit_id = hou.organization_id(+)
--and papf.person_number = :p_person_number -- parameter
papf.person_id,
papf.start_date,
ppnf.full_name employee_full_name,
paam.assignment_number,
hou.name business_unit_name
from per_all_people_f papf,
per_all_assignments_m paam,
per_person_names_f ppnf,
hr_organization_units hou
where 1 = 1
and trunc(sysdate) between papf.effective_start_date and
papf.effective_end_date
and papf.person_id = ppnf.person_id
and trunc(sysdate) between ppnf.effective_start_date and
ppnf.effective_end_date
and ppnf.name_type = 'GLOBAL'
and papf.person_id = paam.person_id
and trunc(sysdate) between paam.effective_start_date and
paam.effective_end_date
and paam.assignment_status_type in ( 'ACTIVE' ) -- Active Assignment
and paam.assignment_type in ( 'E' ) -- Type Employee
and paam.primary_flag = 'Y' -- primary assignment
and paam.business_unit_id = hou.organization_id(+)
--and papf.person_number = :p_person_number -- parameter
No comments:
Post a Comment