SELECT
  RTRIM(AQTYPE) AS aqtype,
  RTRIM(AQPART) AS aqpart,
  "AQSEQ#" AS "aqseq#",
  "AQLIN#" AS "aqlin#",
  RTRIM(AQMTLP) AS aqmtlp,
  RTRIM(AQMTLD) AS aqmtld,
  AQQPPC AS aqqppc,
  RTRIM(AQUNIT) AS aqunit,
  AQSQTY AS aqsqty,
  AQQTYM AS aqqtym,
  RTRIM(AQBLWT) AS aqblwt,
  RTRIM(AQBK01) AS aqbk01,
  RTRIM(AQSTYP) AS aqstyp,
  AQLEAD AS aqlead,
  RTRIM(AQMAJG) AS aqmajg,
  AQITM AS aqitm,
  RTRIM(AQITMX) AS aqitmx,
  RTRIM(AQBK02) AS aqbk02,
  RTRIM(AQALLC) AS aqallc,
  RTRIM(AQBACK) AS aqback,
  AQSCRP AS aqscrp,
  RTRIM(AQRQBY) AS aqrqby,
  RTRIM(AQSTKL) AS aqstkl,
  RTRIM(AQBK03) AS aqbk03,
  RTRIM(AQDRAW) AS aqdraw,
  RTRIM(AQDFLC) AS aqdflc,
  RTRIM(AQFUT1) AS aqfut1,
  RTRIM(AQFUT2) AS aqfut2,
  RTRIM(AQFUT3) AS aqfut3,
  RTRIM(AQFUT4) AS aqfut4,
  RTRIM(AQFUT5) AS aqfut5,
  RTRIM(AQFUT6) AS aqfut6,
  RTRIM(AQFUT7) AS aqfut7,
  RTRIM(AQFUT8) AS aqfut8,
  RTRIM(AQFUT9) AS aqfut9,
  RTRIM(AQFUTA) AS aqfuta,
  AQFUTB AS aqfutb,
  AQFUTC AS aqfutc,
  AQFUTD AS aqfutd,
  AQFUTE AS aqfute,
  RTRIM(AQDEPT) AS aqdept,
  RTRIM(AQRESC) AS aqresc,
  RTRIM(AQPLNT) AS aqplnt,
  RTRIM(AQMJCM) AS aqmjcm,
  AQECND AS aqecnd,
  AQECNL AS aqecnl,
  CASE WHEN AQLDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE AQLDAT END AS aqldat,
  RTRIM(AQLECN) AS aqlecn,
  CASE WHEN AQLEDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE AQLEDAT END AS aqledat,
  AQLETME AS aqletme,
  RTRIM(AQFUSG) AS aqfusg,
  RTRIM(AQWUCM) AS aqwucm,
  AQRDCF AS aqrdcf
FROM LGDAT.METHDM
