Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 3548

Getting opening balances as at a certain date

$
0
0

Hi,

 

I have the query below that I am using for a cash flow report (similar to a balance sheet). The thing is that performing the debit - credit, I get the change in values for the period. I would like to add the opening balances to this figure.

 

I am trying to be able to get the opening balances as at the start date. In this case '20150101' but it could be any date. For example, if the date is 1st April, I would like to get the total opening balances as at 1st April.

 

How do I achieve this?

 

/* Fixed Assets 1 */

SELECT T0.AcctCode AS 'SAP Code', T0.AcctName AS 'Description', SUM(T1.Debit - T1.Credit) AS 'Amount-USD',

T0.FatherNum, 1 AS 'Group', 'Assets' [Assets]

FROM OACT T0

LEFT JOIN JDT1 T1 ON T0.[AcctCode] = T1.[Account]

WHERE T0.AcctCode LIKE '111%' AND T0.Levels = 5

AND (T1.RefDate BETWEEN '20150101' AND '20151231')

GROUP BY T0.AcctCode, T0.AcctName, T0.FatherNum

UNION ALL

/* Prepaid Expenses and Advance Income Tax 2 */

SELECT T0.AcctCode AS 'SAP Code', T0.AcctName AS 'Description', SUM(T1.Debit - T1.Credit) AS 'Amount-USD',

T0.FatherNum, 2 AS 'Group', 'Assets' [Assets]

FROM OACT T0

LEFT JOIN JDT1 T1 ON T0.[AcctCode] = T1.[Account]

WHERE T0.AcctCode LIKE '114%' AND T0.Levels = 5

AND (T1.RefDate BETWEEN '20150101' AND '20151231')

GROUP BY T0.AcctCode, T0.AcctName, T0.FatherNum

 

Regards,

 

Kinyanjui


Viewing all articles
Browse latest Browse all 3548

Trending Articles