[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SQL Query Help
- Subject: Re: SQL Query Help
- From: "Armaghan Saqib" <..hidden..>
- Date: Mon, 4 Jun 2007 21:27:24 -0700
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 <..hidden..> 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
..hidden..
https://lists.sourceforge.net/lists/listinfo/ledger-smb-users