SELECT
  SUM(
    CASE
      WHEN h.HOLDREASONNAME NOT IN ({{ NON_QUALITY_REASONS }}) THEN NVL(h.QTY, 0)
      ELSE 0
    END
  ) AS quality_count,
  SUM(
    CASE
      WHEN h.HOLDREASONNAME IN ({{ NON_QUALITY_REASONS }}) THEN NVL(h.QTY, 0)
      ELSE 0
    END
  ) AS non_quality_count,
  SUM(NVL(h.QTY, 0)) AS all_count
FROM DWH.DW_MES_HOLDRELEASEHISTORY h
WHERE h.RELEASETXNDATE IS NULL
