SELECT
  RTRIM(AADEPT) AS aadept,
  RTRIM(AABLNK) AS aablnk,
  RTRIM(AADNME) AS aadnme,
  AASTDR AS aastdr,
  AABRDR AS aabrdr,
  AAMACH AS aamach,
  AABRDP AS aabrdp,
  AADFTC AS aadftc,
  AASTIM AS aastim,
  AAVBRD AS aavbrd,
  RTRIM(AAFRML) AS aafrml,
  RTRIM(AARCVL) AS aarcvl,
  RTRIM(AAINSP) AS aainsp,
  RTRIM(AAPLNT) AS aaplnt,
  RTRIM(AAOSRV) AS aaosrv,
  AAVBRP AS aavbrp,
  RTRIM(AAWPDR) AS aawpdr,
  RTRIM(AAWPRV) AS aawprv,
  AAMAXH AS aamaxh,
  RTRIM(AAUSLF) AS aauslf,
  RTRIM(AAUSLV) AS aauslv,
  RTRIM(AACUSR) AS aacusr,
  CASE WHEN AACDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE AACDAT END AS aacdat,
  AACTIM AS aactim,
  RTRIM(AAUUSR) AS aauusr,
  CASE WHEN AAUDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE AAUDAT END AS aaudat,
  AAUTIM AS aautim,
  RTRIM(AAFUT1) AS aafut1,
  RTRIM(AAFUT2) AS aafut2,
  RTRIM(AAFUT3) AS aafut3,
  RTRIM(AAFUT4) AS aafut4,
  RTRIM(AAFUT5) AS aafut5,
  RTRIM(AAFUT6) AS aafut6,
  AAFUT7 AS aafut7,
  RTRIM(AAFLG1) AS aaflg1,
  RTRIM(AAFLG2) AS aaflg2,
  RTRIM(AAFLG3) AS aaflg3,
  RTRIM(AAFLG4) AS aaflg4,
  RTRIM(AAFLG5) AS aaflg5,
  RTRIM(AAVCOD) AS aavcod,
  RTRIM(AALBPST) AS aalbpst,
  RTRIM(AAVRPR) AS aavrpr
FROM LGDAT.DEPTS
