Skip to Content
author's profile photo Former Member
Former Member

Query for Trial Balance (Grouping Account names by L4)

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

Untitled.png (24.7 kB)
Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Apr 01, 2015 at 12:59 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 31, 2015 at 04:44 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Mar 31, 2015 at 05:24 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.