cancel
Showing results for 
Search instead for 
Did you mean: 

Query for Trial Balance (Grouping Account names by L4)

kinyanjui_kamau
Participant
0 Kudos

Hi all,

I have a sample Chart of Accounts Level 4 as in the image below.

I want to have a query for a trial balance level 4 such that I get Account Codes, Account Names and Balances as per the same level 4.

The results should look like:

611110    Management Staff Salaries         -5,250,254.87

611120   Subordinate Staff Wages             -2,187,123.13

611140   Leave Pay & Travel Allowance       -987,322.00

611160   Travelling Expenses                     -1,567,873.76               etc........(Compare this to above image)

How do I modify the below query to get the results above?

SELECT DISTINCT T2.AcctCode, T2.AcctName, SUM(T1.Debit - T1.Credit) AS 'Balance'

FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.[TransId] = T1.[TransId]

INNER JOIN OACT T2 ON T1.[Account] = T2.[AcctCode]

WHERE T0.TaxDate BETWEEN '2014-09-01' AND '2014-09-30'

GROUP BY T2.AcctCode, T2.AcctName

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Try:

SELECT T3.AcctCode, T3.AcctName, SUM(T1.Debit - T1.Credit) AS 'Balance'

FROM OJDT T0

INNER JOIN JDT1 T1 ON T0.[TransId] = T1.[TransId]

INNER JOIN OACT T2 ON T1.[Account] = T2.[AcctCode]

INNER JOIN OACT T3 ON T3.[AcctCode] = T2.[FatherNum]

WHERE T0.TaxDate BETWEEN '2014-09-01' AND '2014-09-30'

GROUP BY T3.AcctCode, T3.AcctName

Thanks,

Gordon

Answers (3)

Answers (3)

mateoalp23
Newcomer
0 Kudos

Hello, how to do this same query in level 3?

former_member184146
Active Contributor
0 Kudos

try this

SELECT DISTINCT T2.AcctCode, T2.AcctName, SUM(T1.Debit - T1.Credit) AS 'Balance'

FROM OJDT T0 INNER JOIN JDT1 T1 ON T0.[TransId] = T1.[TransId]

INNER JOIN OACT T2 ON T1.[Account] = T2.[AcctCode]

WHERE T0.TaxDate BETWEEN '2006-09-01' AND '2014-09-30' AND T2.Levels=4

GROUP BY T2.AcctCode, T2.AcctName

frank_wang6
Active Contributor
0 Kudos

SELECT * FROM OACT T0

ORDER BY GroupMask, GrpLine

Using this query will give you the correct sequence as Chart of Account, so just pay attention to FatherNum. With the help to group sub account with their FatherNum, you should be able to generate what you want. If you can not do it, let us know.

Frank