Former Member

# cumulative balance - which table?

Hi there, I am writing a fairly simple query from JDT1, but i can't find the cumulative balance column in either ODJT or JDT1. is it in a different table or is there a formula i should write?

thanks, my example query is below:

SELECT T1.[TransId], T1.[Account], T1.[CreatedBy], T1.[ContraAct], T1.[LineMemo], T1.[Credit], T1.[Debit], T1.[DebCred], FROM [dbo].[JDT1] T1 INNER JOIN OJDT T2 ON T1.TransId = T2.TransId WHERE T1.[Account] = '[%0]' and T1.[RefDate] between '[%1]' and '[%2]'

10|10000 characters needed characters exceeded

### Related questions

Posted on Feb 10, 2010 at 04:37 PM

Hello Groovy,

You can use the word SUM to sum the different values.

E.g. this sums the values of both credit and debit side and it was used in the query generator:

SELECT sum(T0.[Debit]) + sum(T0.[Credit]) FROM JDT1 T0 INNER JOIN OJDT T1 ON T0.TransId = T1.TransId WHERE T1.[TransId] = '95' group by t1.transid

or if you want the total of the column you can use:

select SUM (debit) from jdt1 where transid = 'XXX'

and it will sum the total of debit for that transid.

Thank you.

Marcella Rivi

10|10000 characters needed characters exceeded
• Former Member
Posted on Feb 10, 2010 at 04:25 PM

Hi,

There is no such field or table for you to hold those cumulative balances. They are calculated on the fly in run time application.

One option for you would be: export your query result to Excel and get those cumulative balances by a new column with a simple formula.

Thanks,

Gordon