April15Hater
Accountant
- Local time
- Today, 17:29
- Joined
- Sep 12, 2008
- Messages
- 349
Hi,
I am trying to create aging columns using a sub-select. The query is to list each account, then age the amounts via columns. My problem is that the column it creates with the subselect shows the total amount for all accounts rather than the single one I am trying to resolve. I think I need to add an additional criterion to the WHERE clause of the sub-select, but I'm just not sure what.
I am trying to create aging columns using a sub-select. The query is to list each account, then age the amounts via columns. My problem is that the column it creates with the subselect shows the total amount for all accounts rather than the single one I am trying to resolve. I think I need to add an additional criterion to the WHERE clause of the sub-select, but I'm just not sure what.
Code:
SELECT tblTLP_CRSP_Outstanding.TRecsAccount, tblTLP_CRSP_Outstanding.Amount,
(SELECT sum(Amount) FROM tblTLP_CRSP_Outstanding WHERE datediff("d", EffectiveDate, now()) < 31) as 30Days
FROM tblTLP_CRSP_Outstanding;