SUBSTR(LISTAGG(NCT.DESCRIPTION || ',') WITHIN GROUP(ORDER BY ZAB.ABNORMAL_NO),0,LENGTH(LISTAGG(NCT.DESCRIPTION || ',') WITHIN GROUP(ORDER BY ZAB.ABNORMAL_NO))-1) NC_CODE_DESCRIPTION
FROM Z_ABNORMAL_BILL ZAB
LEFT JOIN ITEM I ON ZAB.ITEM_BO = I.HANDLE
LEFT JOIN ITEM_T IT ON I.HANDLE = IT.ITEM_BO AND IT.LOCALE = #{language}
LEFT JOIN Z_NWA_USER ZNU ON ZNU.USER_NAME = ZAB.CREATED_USER AND ZNU.SITE = ZAB.SITE
LEFT JOIN SHOP_ORDER SO ON SO.SHOP_ORDER = ZAB.SHOP_ORDER AND SO.SITE = ZAB.SITE
LEFT JOIN CUSTOM_FIELDS CF ON CF.HANDLE = SO.HANDLE AND CF."ATTRIBUTE" = 'WORK_ORDER'
LEFT JOIN Z_ABNORMAL_NC_CODE ZANC ON ZANC.ABNORMAL_BILL_BO = ZAB.HANDLE
LEFT JOIN NC_CODE_T NCT ON NCT.NC_CODE_BO = 'NCCodeBO:'|| ZAB.SITE || ',' || ZANC.NC_CODE AND NCT.LOCALE = #{language}
<where>
@ -955,10 +958,13 @@
<iftest="abnormalBill.reportFrom != null and abnormalBill.reportFrom != ''">
AND zab.REPORT_FROM = #{abnormalBill.reportFrom}
</if>
<iftest="abnormalBill.workOrder != null and abnormalBill.workOrder != ''">
AND CF.VALUE = #{abnormalBill.workOrder}
</if>
</if>
</where>
GROUP BY zab.ABNORMAL_NO,zab.STATUS,it.DESCRIPTION,zab.CREATED_DATE_TIME,zab.RESPONSE_DATE_TIME,