SELECT
  RTRIM(BXPART) AS bxpart,
  RTRIM(BXLOT) AS bxlot,
  RTRIM(BXSTOK) AS bxstok,
  RTRIM(BXUNIT) AS bxunit,
  BXQTOH AS bxqtoh,
  BXQTAL AS bxqtal,
  BXMNQT AS bxmnqt,
  BXMXQT AS bxmxqt,
  BXQTOD AS bxqtod,
  CASE WHEN BXPDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE BXPDAT END AS bxpdat,
  RTRIM(BXCCGP) AS bxccgp,
  BXQTSO AS bxqtso,
  RTRIM(BXPLNT) AS bxplnt,
  RTRIM(BXFUT1) AS bxfut1,
  RTRIM(BXFUT2) AS bxfut2,
  RTRIM(BXFUT3) AS bxfut3,
  RTRIM(BXFUT4) AS bxfut4,
  RTRIM(BXFUT5) AS bxfut5,
  RTRIM(BXFUT6) AS bxfut6,
  RTRIM(BXFUT7) AS bxfut7,
  RTRIM(BXFUT8) AS bxfut8,
  RTRIM(BXFUT9) AS bxfut9,
  BXFUTA AS bxfuta,
  CASE WHEN BXLEXP IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE BXLEXP END AS bxlexp
FROM LGDAT.STKB
WHERE 
  BXQTOH <> 0
