Average Balance "life"

From: telenieko(at)gmail(dot)com
To: pgsql-general(at)postgresql(dot)org
Subject: Average Balance "life"
Date: 2012-10-30 11:34:13
Message-ID: 1e95e269-693e-4ec1-bdea-8bc5a33dbfc5@googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 balances but 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 this is 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 find accounting errors.

Thanks,
marc

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Rodrigo Pereira da Silva 2012-10-30 12:05:01 Re: Too much clients connected to the PostgreSQL Database
Previous Message RAJDEEP SARDAR 2012-10-30 11:07:47 Select Query Implementation:Details needed