Hello
I'm trying to reconcile a list of transactional GL data against a account balance summary file and I run into an error noting that I'm attempting to use two fields (TbBegBal and TbEndBal) that are not part of the aggregate function. Since I have both fields within my aggregate functions, I don't understand why I'm receiving the error. Could it be the order in which they are appearing in the aggregate? I've tried rearranging it but still received the error. My query is below. Any help is appreciated.
SELECT
GlAcct,
sum(IIf(GLAmount>0,GLAmount,0)) AS GL_DRActivity,
sum(IIf(GLAmount<0,GLAmount,0)) AS GL_CRActivity,
Round(Sum(GLAmount) + TBBegBal,0) AS GL_Q4EndBal,
Round((Sum(GLAmount)+ TBBegBal)- TBEndBal,0) AS AcctBalRecon
FROM corp LEFT JOIN Tbal ON corp.GLAcct=Tbal.TbAcct
GROUP BY corp.GLAcct;
I'm trying to reconcile a list of transactional GL data against a account balance summary file and I run into an error noting that I'm attempting to use two fields (TbBegBal and TbEndBal) that are not part of the aggregate function. Since I have both fields within my aggregate functions, I don't understand why I'm receiving the error. Could it be the order in which they are appearing in the aggregate? I've tried rearranging it but still received the error. My query is below. Any help is appreciated.
SELECT
GlAcct,
sum(IIf(GLAmount>0,GLAmount,0)) AS GL_DRActivity,
sum(IIf(GLAmount<0,GLAmount,0)) AS GL_CRActivity,
Round(Sum(GLAmount) + TBBegBal,0) AS GL_Q4EndBal,
Round((Sum(GLAmount)+ TBBegBal)- TBEndBal,0) AS AcctBalRecon
FROM corp LEFT JOIN Tbal ON corp.GLAcct=Tbal.TbAcct
GROUP BY corp.GLAcct;