Average Balance "life" - Mailing list pgsql-general

From telenieko@gmail.com
Subject Average Balance "life"
Date
Msg-id 1e95e269-693e-4ec1-bdea-8bc5a33dbfc5@googlegroups.com
Whole thread Raw
Responses Re: Average Balance "life"  ("David Johnston" <polobo@yahoo.com>)
List pgsql-general
Hi there,

Not sure if this is the right place to post this question:

I'm tryting to find a way to do the following without going row by row on the client program doing the calculations:

I've got a "movements" table (from an accounting program) for which I've already done monthly balances and running
balancesbut now I need to calculate the "life" of the balances. 

Ie, account 1 is 0 and gets 1000 on day 1, -1000 on day 3. That would make a life of two days for this balance. Note
thisis completely diferent to "average balance". 

In words that would be "Every time money goes into this account it takes an average of X days to go out".

Any ideas on how could I do this calculation inside PostgreSQL to avoid transfering all rows to the client?

In case you are curious, I want to do this calculation to see which accounts have "balance lifes" to long in order to
findaccounting errors. 

Thanks,
marc


pgsql-general by date:

Previous
From: r d
Date:
Subject: fuzzystrmatch module buggy? observations
Next
From: RAJDEEP SARDAR
Date:
Subject: Select Query Implementation:Details needed