Sunday 5 June 2016

Querry to find Active Employees Positions and limit

select distinct hr.name,gs.CURRENCY_CODE,pap.EMPLOYEE_NUMBER,pap.full_name,
HR_GENERAL.DECODE_POSITION_LATEST_NAME(PAa.POSITION_ID) Position_name,--pog.CONTROL_GROUP_NAME position,
pj.name "Job name",pcf.CONTROL_FUNCTION_NAME,
pcr.RULE_TYPE_CODE,pcr.OBJECT_CODE,pcr.AMOUNT_LIMIT,
segment1_high||segment2_high||segment3_high||segment4_high||segment5_high||segment6_high||segment7_high||segment8_high "High",
segment1_low||segment2_low||segment3_low||segment4_low||segment5_low||segment6_low||segment7_low||segment8_low "low"
from po_control_groups_all pog,po_control_functions pcf,PO_POSITION_CONTROLS_all ppc,
PER_JOBS pj,PO_CONTROL_RULES pcr,hr_operating_units hr,
PER_ALL_ASSIGNMENTS_F paa,
per_all_people_f pap,
gl_ledgers gs
where pog.CONTROL_GROUP_ID= ppc.CONTROL_GROUP_ID
and ppc.CONTROL_FUNCTION_ID=pcf.CONTROL_FUNCTION_ID
and pog.org_id=ppc.org_id
and pj.job_id=ppc.job_id
and pcr.CONTROL_GROUP_ID=pog.CONTROL_GROUP_ID
and nvl(pcr.INACTIVE_DATE,sysdate)>=sysdate
and hr.organization_id=pog.org_id
and paa.job_id=pj.job_id
and paa.person_id=pap.person_id
and  nvl(pap.EFFECTIVE_END_DATE,sysdate)>=sysdate
and gs.ledger_id=hr.SET_OF_BOOKS_ID
and ppc.POSITION_ID=paa.position_id
and ppc.position_id is not null
and  nvl(paa.EFFECTIVE_END_DATE,sysdate)>=sysdate
and paa.ASSIGNMENT_STATUS_TYPE_ID=1
-- and rownum=1
order by hr.name,pap.employee_number,pcf.CONTROL_FUNCTION_NAME

No comments:

Post a Comment