Skip site navigation (1) Skip section navigation (2)

Re: aggregate function ?

From: Richard Broersma Jr <rabroersma(at)yahoo(dot)com>
To: Raimon Fernandez <coder(at)montx(dot)com>, pgsql-novice(at)postgresql(dot)org
Subject: Re: aggregate function ?
Date: 2007-05-16 15:02:11
Message-ID: 954410.14409.qm@web31806.mail.mud.yahoo.com (view raw or flat)
Thread:
Lists: pgsql-novice
One last change...

--- Raimon Fernandez <coder(at)montx(dot)com> wrote:

> hi again ...
> 
> GlobalGest=#  SELECT A1.oid, A1.concepte, A1.deure, A1.haver,
>             sum( COALESCE( A1.deure, 0 ) -
>                  COALESCE( A2.haver, 0 )) AS value_sum
>        FROM Assentaments AS A1
> INNER JOIN Assentaments AS A2
>          ON A1.oid <= A2.oid
>         AND A1.numero = A2.numero  --this should only preform a sum  
This is only a comment and not needed ^


    SELECT A1.oid, A1.concepte, A1.deure, A1.haver,
           sum( COALESCE( A1.deure, 0 ) -
                COALESCE( A2.haver, 0 )) AS value_sum
      FROM Assentaments AS A1
INNER JOIN Assentaments AS A2
        ON A1.oid >= A2.oid  -- change "<=" to ">="
       AND A1.numero = A2.numero
     WHERE A1.numero=11189
  GROUP BY A1.oid, A1.concepte, A1.deure, A1.haver
  ORDER BY A1.oid;


Regards,
Richard Broersma Jr.

In response to

pgsql-novice by date

Next:From: Richard Broersma JrDate: 2007-05-16 15:10:06
Subject: Re: aggregate function ?
Previous:From: Raimon FernandezDate: 2007-05-16 14:31:38
Subject: Re: aggregate function ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group