Tuesday, 23 November 2021

SQL:Employees without performance goals

Select distinct papf.person_number, ppnf.full_name, to_char(ppos.date_start,'DD-MM-YYYY'), EMPLOYMENT_CATEGORY, EMPLOYEE_CATEGORY,pgf.GRADE_CODE
from
per_all_people_f papf,
per_person_names_f ppnf,
per_grades_f pgf,
per_all_assignments_m paam,
per_periods_of_service ppos
where papf.person_id = ppos.person_id
and papf.person_id = paam.person_id
and papf.person_id = ppnf.person_id
and paam.grade_id = pgf.grade_id
and paam.effective_latest_change(+) = 'Y'
and upper(paam.ASSIGNMENT_STATUS_TYPE) = 'ACTIVE'
and paam.PRIMARY_FLAG(+) = 'Y'
and paam.assignment_type(+) = 'E'
and paam.PRIMARY_ASSIGNMENT_FLAG(+) = 'Y'
and paam.PRIMARY_WORK_RELATION_FLAG(+) = 'Y'
and paam.SYSTEM_PERSON_TYPE(+) = 'EMP'
and ppnf.name_type = 'GLOBAL'
and pgf.ACTIVE_STATUS = 'A'
and ppos.PRIMARY_FLAG = 'Y'
and ppos.PERIOD_TYPE = 'E'
and paam.legislation_code = ppos.legislation_code
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 paam.effective_start_date AND paam.effective_end_date
and TRUNC(SYSDATE) BETWEEN pgf.effective_start_date AND pgf.effective_end_date
and ppos.date_start = (select max(ppos_in.date_start) 
from per_periods_of_service ppos_in
where ppos_in.person_id = ppos.person_id
and ppos_in.PRIMARY_FLAG = 'Y'
and ppos_in.PERIOD_TYPE = 'E'
)
and papf.person_id in (
select distinct person_id
from per_all_assignments_m paam
where 1=1
and effective_latest_change(+) = 'Y'
and upper(ASSIGNMENT_STATUS_TYPE) = 'ACTIVE'
and PRIMARY_FLAG(+) = 'Y'
and assignment_type(+) = 'E'
and PRIMARY_ASSIGNMENT_FLAG(+) = 'Y'
and PRIMARY_WORK_RELATION_FLAG(+) = 'Y'
and SYSTEM_PERSON_TYPE(+) = 'EMP'
and TRUNC(SYSDATE) BETWEEN paam.effective_start_date AND paam.effective_end_date
minus
select distinct person_id
from HRG_GOALS
where GOAL_TYPE_CODE = 'PERFORMANCE'
)
order by 1 desc

No comments:

Post a Comment