I have two tables:
Table GL
TRANS_NBR BASE_AMOUNT CTRL GRP
120211282 -7200 77
120211282 -300 77
120211282 -10000 76
Table AP
TRANS_NBR BASE_AMOUNT CODE
120211282 7500 Wire
120211282 10000 ACH
I need to be able to add the Code column to the GL Table, but the the amounts need to be aggregated first. Does anyone know how to accomplish this? Thanks
I’ve tried this from Tom Ingram’s answer,
SELECT GLTRANS.REFERENCE, SUM(GLTRANS.BASE_AMOUNT) AS SUM_BASE_AMOUNT, CBCHECK.CODE
FROM (
SELECT GLTRANS.REFERENCE, GLTRANS.BASE_AMOUNT, CBCHECK.CODE
FROM LAWSON_PRODST.LAWSON.GLTRANS
LEFT JOIN LAWSON_PRODTST.LAWSON.CBCHECK on CBCHECK.TRANS_NBR = GLTRANS.REFERENCE
UNION
SELECT GLTRANS.REFERENCE, GLTRANS.BASE_AMOUNT, CBCHECK.CODE
FROM LAWSON_PRODTST.LAWSON.CBCHECK
)
GROUP BY GLTRANS.REFERENCE
But I get an “incorrect syntax near keyword “group.” Can anyone spot the issue? Thanks
Try something like this