SELECT DISTINCT
GROUP_CONCAT(
DISTINCT pch.erpContractNumber
) AS fbk22,
poh.*, IFNULL(eei.shortName, eei.fullName) AS companyShortName,
GROUP_CONCAT(DISTINCT poi.fbk7) AS materialNumber
FROM
purchase_order_header poh
LEFT JOIN purchase_order_item poi ON poh.purchaseOrderNumber = poi.purchaseOrderNumber
AND poh.elsAccount = poi.elsAccount
LEFT JOIN els_enterprise_info eei ON eei.elsAccount = poh.toElsAccount
LEFT JOIN purchase_contract_head pch ON pch.elsAccount = poh.elsAccount
AND poh.purchaseOrderNumber = pch.erpContractNumber
AND pch.fbk15 = "1"
WHERE
poh.elsAccount = "120000"
AND poh.orderStatus IN ("0","1","2","3","4","5","6","7")
AND poh.orderSendStatus IN ("0")
GROUP BY
poh.purchaseOrderNumber
ORDER BY
poh.logtime DESC,
poh.purchaseOrderNumber DESC