SELECT P.BUSINESS_GROUP_ID
, A.ORGANIZATION_ID, P.PERSON_ID EMPLOYEE_ID
, A.ASSIGNMENT_ID
, P.LAST_UPDATE_DATE
, P.LAST_UPDATED_BY
, P.LAST_UPDATE_LOGIN
, P.CREATION_DATE
, P.CREATED_BY
, P.EMPLOYEE_NUMBER
, P.FULL_NAME
, P.FIRST_NAME
, P.MIDDLE_NAMES
, P.LAST_NAME
, P.TITLE
, A.LOCATION_ID
, A.SUPERVISOR_ID
, A.SET_OF_BOOKS_ID
, A.DEFAULT_CODE_COMB_ID
, P.EXPENSE_CHECK_SEND_TO_ADDRESS
, P.EMAIL_ADDRESS
, P.WORK_TELEPHONE
, NVL(A.EFFECTIVE_END_DATE
, SYSDATE-1) EFFECTIVE_END_DATE
, P.ATTRIBUTE1
, P.ATTRIBUTE2
, P.ATTRIBUTE3
, P.ATTRIBUTE4
, P.ATTRIBUTE5
, P.ATTRIBUTE_CATEGORY
, ORG.NAME ORG_NAME
FROM PER_PEOPLE_F P
, PER_ASSIGNMENTS_F A
, HR_ORGANIZATION_UNITS ORG
, PER_ASSIGNMENT_STATUS_TYPES PAST
WHERE A.PERSON_ID = P.PERSON_ID
AND A.ASSIGNMENT_STATUS_TYPE_ID = PAST.ASSIGNMENT_STATUS_TYPE_ID
AND PAST.PER_SYSTEM_STATUS IN ('ACTIVE_ASSIGN'
, 'SUSP_ASSIGN')
AND A.PRIMARY_FLAG = 'Y'
AND TRUNC(SYSDATE) BETWEEN P.EFFECTIVE_START_DATE
AND P.EFFECTIVE_END_DATE
AND TRUNC(SYSDATE) BETWEEN A.EFFECTIVE_START_DATE
AND A.EFFECTIVE_END_DATE
AND P.EMPLOYEE_NUMBER IS NOT NULL
AND A.ASSIGNMENT_TYPE = 'E'
AND A.ORGANIZATION_ID = ORG.ORGANIZATION_ID