select
A.ACCT as acct, COUNT(TRANS_key) as payments
from
DEBT A
join
TRANS B on B.DEBT_KEY = A.DEBT_KEY
join
TRANS_CODE C on C.TRANS_CODE = B.TRANS_CODE
join
CLIENT D on D.CLIENT_KEY = A.CLIENT_KEY
join
STATUS S on S.STAT_KEY = A. STAT_KEY
where
S.CATEGORY = 'A' and D.CLIENT_KEY = 43
Error:
Cannot perform an aggregate function on an expression containing an
aggregate or a subquery.
I am getting the error above when running this. I am not sure if I should be joining these tables differently or not, but I need this to be working.
All other selects have to be group by. Use this