SELECT A.EMPLID,
A.COUNTRY_NM_FORMAT,
A.NAME_DISPLAY,
A.NAME_INITIALS,
A.NAME_PREFIX,
A.NAME_SUFFIX,
A.NAME_ROYAL_PREFIX,
A.NAME_ROYAL_SUFFIX,
A.NAME_TITLE,
A.LAST_NAME_SRCH,
A.FIRST_NAME_SRCH,
A.LAST_NAME,
A.FIRST_NAME,
A.MIDDLE_NAME,
A.SECOND_LAST_NAME,
A.SECOND_LAST_SRCH,
A.NAME_AC,
A.PREF_FIRST_NAME,
A.PARTNER_LAST_NAME,
A.PARTNER_ROY_PREFIX,
A.LAST_NAME_PREF_NLD,
A.NAME_DISPLAY,
A.NAME_FORMAL,
A.NAME_DISPLAY_SRCH,
A.NAME_TYPE,
A.EFFDT,
A.NAME
FROM PS_NAMES A
WHERE A.NAME_TYPE = 'PRI'
AND A.EFFDT = (SELECT MAX(B.EFFDT)
FROM PS_NAMES B
WHERE B.EMPLID = A.EMPLID
AND B.NAME_TYPE = A.NAME_TYPE
AND B.EFFDT <= TO_DATE(TO_CHAR(SYSDATE, 'YYYY-MM-DD'),
'YYYY-MM-DD'));