For a single account (31488) balance up to a particular 31-Dec-2006: ==================================================
SELECT SUM(amount) FROM acc_trans WHERE transdate <= '31.12.2006' AND chart_id IN (SELECT id FROM chart WHERE accno='31488') For a range of accounts: ================== SELECT accno, description, (SELECT SUM(amount) FROM acc_trans WHERE transdate <= '31.12.2006' AND acc_trans.chart_id = chart.id) AS balance FROM chart WHERE accno LIKE '1%' ORDER BY accno Work in SL, should work in LSMB. Please see http://www.ledger123.com/sqlreports for more examples. Regards Armaghan On 6/4/07, M Lubratt <[EMAIL PROTECTED]> wrote: > Hello! > > I need to write a query that will give me the value of a balance sheet > account on a specific day. I know I could generate a balance sheet report, > but then I'd have to parse it to get what I need. There are several layers > that I'm going to wrap the query in; I just don't know how to do this part. > Could someone familiar with the schema point me in the right direction? > > Thanks! > Mark > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Ledger-smb-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/ledger-smb-users ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Ledger-smb-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ledger-smb-users
