Get all employees within Student Affairs (by mail code, ignoring students and temporary staff)

SELECT LAST_NAME, FIRST_NAME, MIDDLE_NAME,

CSU_ID,

CASE WHEN PROPER_NAME_ADDRESS IS NULL THEN EMAIL_ADDRESS ELSE PROPER_NAME_ADDRESS END EMAIL,

EMPLOYEE_TITLE,

EMPLOYEE_DEPARTMENT,

EMPLOYEE_DEPARTMENT_NUMBER,

EMPLOYEE_TYPE

FROM CSUBAN.CSUG_DIRECTORY_ALL

WHERE ((EMPLOYEE_DEPARTMENT_NUMBER BETWEEN 8001 AND 8105) OR

(EMPLOYEE_DEPARTMENT_NUMBER = 1032))

AND (ACCOUNT_TYPE = ‘P’) AND (LIVE_LAG_START_DATE IS NULL)

AND (DEAD_LAG_START_DATE IS NULL)

AND (ACTIVE_FLAG_EIDDATA = ‘Y’)

AND (EMPLOYEE_TYPE NOT LIKE ‘%Student Hourly%’)

AND (EMPLOYEE_TYPE NOT LIKE ‘%Retiree%’)

AND (EMPLOYEE_TYPE NOT LIKE ‘%Temporary%’)

AND (EMAIL_ADDRESS IS NOT NULL)

AND (ACTIVE_FLAG_EMAIL <> ‘N’)

AND (ADMIN_ACCT_FLAG <> ‘Y’)

ORDER BY LAST_NAME, FIRST_NAME