SELECT
  RTRIM(LQSTKL) AS lqstkl,
  RTRIM("LQBIN#") AS "lqbin#",
  RTRIM(LQPART) AS lqpart,
  RTRIM("LQLOT#") AS "lqlot#",
  LQQTYH AS lqqtyh,
  "LQBTC#" AS "lqbtc#",
  CASE WHEN LQRDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE LQRDAT END AS lqrdat,
  CASE WHEN LQIDAT IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE LQIDAT END AS lqidat,
  LQQTY AS lqqty,
  RTRIM(LQUNIT) AS lqunit,
  RTRIM(LQPLNT) AS lqplnt,
  LQMINQ AS lqminq,
  LQMAXQ AS lqmaxq,
  LQRPLQ AS lqrplq,
  CASE WHEN LQLEXP IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE LQLEXP END AS lqlexp
FROM LGDAT.BINB
WHERE
    LQQTY <> 0
