This SQL query selects and joins data from multiple tables to retrieve personal information like names and addresses, employment information like employer and location, and identifiers like Social Security Number. It filters for current active records and primary assignments to extract key data for a report on current employees, including their personal details, employment details, and identifiers.
This SQL query selects and joins data from multiple tables to retrieve personal information like names and addresses, employment information like employer and location, and identifiers like Social Security Number. It filters for current active records and primary assignments to extract key data for a report on current employees, including their personal details, employment details, and identifiers.
This SQL query selects and joins data from multiple tables to retrieve personal information like names and addresses, employment information like employer and location, and identifiers like Social Security Number. It filters for current active records and primary assignments to extract key data for a report on current employees, including their personal details, employment details, and identifiers.
PN.LAST_NAME || '/' || PN.FIRST_NAME || '/' || SUBSTR(MIDDLE_NAMES, 1,1) NAME, 'N' INDICATOR, ADDR.ADDRESS_LINE_1 STREET_ADDRESS, ADDR.TOWN_OR_CITY CITY, ADDR.REGION_2 STATE, ADDR.POSTAL_CODE ZIP, LEMP.NAME EMPLOYER, REG.REGISTRATION_NUMBER FEIN, LOC.ADDRESS1 EMP_STREET_ADDR, LOC.CITY EMP_CITY, LOC.STATE EMP_STATE, LOC.POSTAL_CODE EMP_ZIP FROM PER_ALL_PEOPLE_F APF, PER_NATIONAL_IDENTIFIERS NID, PER_PERSON_NAMES_F PN, PER_PERSON_ADDR_USAGES_F PAUF, PER_ADDRESSES_F ADDR, PER_ALL_ASSIGNMENTS_M AA, PER_PERIODS_OF_SERVICE POS, PER_LEGAL_EMPLOYERS LEMP, XLE_REGISTRATIONS REG, HZ_LOCATIONS LOC WHERE TRUNC(SYSDATE) BETWEEN APF.EFFECTIVE_START_DATE AND APF.EFFECTIVE_END_DATE AND APF.PERSON_ID = NID.PERSON_ID AND NID.NATIONAL_IDENTIFIER_TYPE (+) = 'SSN' AND PN.PERSON_ID = APF.PERSON_ID AND PN.NAME_TYPE = 'GLOBAL' AND TRUNC(SYSDATE) BETWEEN PN.EFFECTIVE_START_DATE AND PN.EFFECTIVE_END_DATE AND PAUF.PERSON_ID(+) = APF.PERSON_ID AND TRUNC(SYSDATE) BETWEEN PAUF.EFFECTIVE_START_DATE (+) AND PAUF.EFFECTIVE_END_DATE (+) AND PAUF.ADDRESS_TYPE (+) = 'MAIL' AND APF.MAILING_ADDRESS_ID = ADDR.ADDRESS_ID(+) AND ADDR.ADDRESS_ID = PAUF.ADDRESS_ID(+) AND TRUNC(SYSDATE) BETWEEN ADDR.EFFECTIVE_START_DATE(+) AND ADDR.EFFECTIVE_END_DATE(+) AND AA.PERSON_ID = APF.PERSON_ID AND AA.ASSIGNMENT_TYPE = 'E' AND AA.PRIMARY_FLAG = 'Y' AND AA.EFFECTIVE_LATEST_CHANGE = 'Y' AND AA.ACTION_CODE = 'HIRE' AND TRUNC(SYSDATE) BETWEEN AA.EFFECTIVE_START_DATE AND AA.EFFECTIVE_END_DATE AND AA.LEGAL_ENTITY_ID = LEMP.ORGANIZATION_ID AND TRUNC(SYSDATE) BETWEEN LEMP.EFFECTIVE_START_DATE AND LEMP.EFFECTIVE_END_DATE AND AA.PERSON_ID = POS.PERSON_ID AND AA.PERIOD_OF_SERVICE_ID = POS.PERIOD_OF_SERVICE_ID AND REG.SOURCE_TABLE (+) = 'XLE_ENTITY_PROFILES' AND REG.SOURCE_ID (+) = LEMP.LEGAL_ENTITY_ID AND REG.IDENTIFYING_FLAG(+) = 'Y' AND LOC.LOCATION_ID(+) = REG.LOCATION_ID