From: | Raimon Fernandez <coder(at)montx(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: aggregate function ? |
Date: | 2007-05-18 06:35:50 |
Message-ID: | 51ACF4CC-811F-4A05-8604-DD0B0CEC813B@montx.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Hi,
I choose because it's an easy example, normally I would change for a
Date selection and another field.
The user selects a compte and a date interval, for example:
compte: 572 0000 01
date init: 15/01/2007
date end: 30/01/2007
The initial sum, would be the compte field plus a date init of the
year, in that case, 01/01/2007 to the date init, 15/01/2007. Here
we'll get the SUM of the two values (deure-haver), and this would be
the initial value of the sum_value to add, so the code would be:
SELECT SUM(deure)-SUM(haver) FROM assentaments WHERE
assentaments.compte='572000001' and assentaments.data >='2007-01-15'
and assentaments.data <='2007-01-30';
Regards,
rai
On 18/05/2007, at 06:49, Richard Broersma Jr wrote:
>
> --- Raimon Fernandez <coder(at)montx(dot)com> wrote:
>> Is this the correct way to add a number to each sum_value ?
>
>> (SELECT deure FROM assentaments WHERE oid=180108)+ sum
> ^^^^^^
> One question why did you choose oid=180108 to identify the row to
> use for adding to your sum. Is
> there some sort of hidden relationship here that you can use craft
> a better select query?
> Basically, the question to ask is, what is the relationship between
> the rolling Sum and the
> initial "shifting" value.
>
> Regards,
> Richard Broersma Jr.
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Broersma Jr | 2007-05-18 15:57:20 | Re: aggregate function ? |
Previous Message | Richard Broersma Jr | 2007-05-18 04:49:01 | Re: aggregate function ? |