RE: GP 2010 Historical Aged Trial Balance report = debits + invoices , less credits and payments?
The title of your post says 'historical aged trial balance', but your post talks about outstanding balances, making it seem like you're looking for the current balance. These are very different.
If you're looking to duplicate the historical aged trial balance in SQL on your own, you have a LOT of work ahead of you. There is a lot of very complicated logic based on a number of parameters and additional tables.
If you're looking for the current balance, you only need the RM20101 table. RM10301 is unposted transactions and RM30101 are historical transactions, neither are part of the current balance.
For the current balance, in RM20101, look at the CURTRXAM, add the CRTRXAM from any transaction with RMDTYPAL < 7 and subtract all other transactions. That should total your current aging.
As Deanne mentioned, there are a number of scripts on my blog that can give you more help with the current aging.