I have an Access query with the following
GL_A.Account,
GL_P.FiscalYear,
GL_P.FiscalPeriod,
GL_P.BeginningBalance,
GL_P.DebitAmount,
GL_P.CreditAmount,
[B
This SQL does the job and returns the table below (with my test data):
SELECT T1.Account
, T1.FiscalYear
, T1.FiscalPeriod
, T1.ActualBeginngBal
, (
SELECT TOP 1 T2.EndingBalance
FROM Table1 T2
WHERE CLNG(T2.FiscalYear & Format(T2.FiscalPeriod,"00")) <
CLNG(T1.FiscalYear & Format(T1.FiscalPeriod,"00")) AND
T2.Account = T1.Account
ORDER BY CLNG(T2.FiscalYear & Format(T2.FiscalPeriod,"00")) DESC
) AS BeginningBalance
, T1.EndingBalance
FROM Table1 T1