SELECT
  B86COMN AS b86comn,
  RTRIM(B86CURC) AS b86curc,
  RTRIM(B86RTTY) AS b86rtty,
  B86EFYY AS b86efyy,
  B86EFPP AS b86efpp,
  CASE WHEN B86EDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE B86EDAT END AS b86edat,
  B86SRTE AS b86srte,
  RTRIM(B86CUSR) AS b86cusr,
  CASE WHEN B86CDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE B86CDAT END AS b86cdat,
  B86CTME AS b86ctme,
  RTRIM(B86UUSR) AS b86uusr,
  CASE WHEN B86UDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE B86UDAT END AS b86udat,
  B86UTME AS b86utme,
  RTRIM(B86FUT1) AS b86fut1,
  RTRIM(B86FUT2) AS b86fut2,
  RTRIM(B86FUT3) AS b86fut3,
  RTRIM(B86FUT4) AS b86fut4,
  RTRIM(B86FUT5) AS b86fut5,
  RTRIM(B86FUT6) AS b86fut6,
  B86FUT7 AS b86fut7,
  B86FUT8 AS b86fut8,
  B86FUT9 AS b86fut9,
  B86FUTA AS b86futa,
  RTRIM(B86FLG1) AS b86flg1,
  RTRIM(B86FLG2) AS b86flg2,
  RTRIM(B86FLG3) AS b86flg3,
  RTRIM(B86FLG4) AS b86flg4,
  RTRIM(B86FLG5) AS b86flg5
FROM LGDAT.CRET
