Re: aggregate function ? - Mailing list pgsql-novice

From Richard Broersma Jr
Subject Re: aggregate function ?
Date
Msg-id 603082.74848.qm@web31811.mail.mud.yahoo.com
Whole thread Raw
In response to Re: aggregate function ?  (Raimon Fernandez <coder@montx.com>)
Responses Re: aggregate function ?  (Raimon Fernandez <coder@montx.com>)
List pgsql-novice
--- Raimon Fernandez <coder@montx.com> wrote:

> Well, that's perfectly ...
>
> Now I'm going to try to understand how this work ...
>
> In the web page that you refer, it also shows how to do it with a
> temporal table/cursor, and I see it's faster there.
>
> You have more options if you need to do some extra operations, but I
> see how powerful SQL can be ...

Really, from a SQL pure-ist point of view, all operations on the database can be and SHOULD BE
preformed with SQL statements as the initial development effort.  The only reason to change a
procedural solution (such as using a cursor) would be if you can achieve better performance by
using a procedure.  However, I would not take the performance results from that web site
seriously.  The are most likely not using PostgreSQL in there test.  And PostgreSQL may favor one
of the query methods over the procedure.  You will have to test for your self which solution is
the best for your environment.

>
> Would be possible with this code to start the sum_value with a
> previous value from another SELECT ?
>
> For example, SELECT SUM(deure)-SUM(haver) FROM assentaments WHERE
> data<2007-01-01;

Sure, you can achieve what you are looking for.  However, you have to know exactly what you want
to achieve AND you have to know the predicates to use to achieve these results.  As to can tell,
for the previous SQL link, there can be various solutions to a problem.  So have performance
advantages over others.  Some of the values that you could tinker with that would can the results
of the query would be:

...
       AND A1.numero = A2.numero
     WHERE A1.numero=11189
...

Regards,
Richard Broersma Jr.

pgsql-novice by date:

Previous
From: Raimon Fernandez
Date:
Subject: Re: aggregate function ?
Next
From: Raimon Fernandez
Date:
Subject: Re: aggregate function ?