Tested in PGSQL build (14300)
SELECT po.POCUSTOMID AS "Order No.",poi.serialno "S.No", poaddfield.UDF_CHAR1 AS "Legal Entity", po.PONAME AS "PO Name", pos.STATUSNAME AS "PO Status", cy.currencyname "Currency", paao.NAME AS "Vendor Name", po.SHIPTO AS "Ship To", po.BILLTO AS "Bill To",ct.componenttypename "Product Type", cd.componentname "Product", poi.description "Additional information about the product", poi.price "Price", poi.quantityordered "Quantity", sum(poi.quantityordered*poi.Price) "Amount", sdu.firstname "Requested By", pogl.GLCODE AS "GL Code", LONGTODATE(po.DATEORDERED) AS "PO Created Date", LONGTODATE(po.DATEORDERED) AS "Ordered Date", ad.ORG_NAME AS "Account" FROM PurchaseOrder po LEFT JOIN POStatus pos ON po.STATUSID=pos.STATUSID LEFT JOIN VendorDefinition pvd ON po.VENDORID=pvd.VENDORID LEFT JOIN SDOrganization paao ON pvd.VENDORID=paao.ORG_ID LEFT JOIN PurchaseGLCodes pogl ON po.GLCODE=pogl.GLCODEID INNER JOIN POAccMapping poacc ON po.PURCHASEORDERID=poacc.PURCHASEORDERID INNER JOIN AccountDefinition ad ON poacc.ACCOUNTID=ad.ORG_ID LEFT JOIN PurchaseOrderItem poi ON po.purchaseorderid=poi.purchaseorderid LEFT JOIN SDUSER sdu on po.requesterid=sdu.userid LEFT JOIN ComponentDefinition cd ON poi.componentid=cd.componentid LEFT JOIN Componenttype ct ON cd.componenttypeid=ct.componenttypeid LEFT JOIN PurchaseOrder_Fields poaddfield ON po.PURCHASEORDERID=poaddfield.PURCHASEORDERID LEFT JOIN Povendorcurrency poc ON po.purchaseorderid=poc.purchaseorderid LEFT JOIN Currency cy ON poc.currencyid=cy.currencyid GROUP BY 1,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20 ORDER BY 1, 2