Re: Sum

From: Jim Martinez <jjm(at)bigbigorg(dot)org>
To: Jean-Luc Lachance <jllachan(at)nsd(dot)ca>
Cc: Marcelo Pereira <gandalf(at)sum(dot)desktop(dot)com(dot)br>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Sum
Date: 2002-03-28 17:43:21
Message-ID: Pine.LNX.4.33.0203281238470.9015-100000@unagi.e-techservices.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

After much thought on Mar 28 Jean-Luc Lachance wrote:

> Marcelo,
>
> Assuming that "cod" is unique and sequencial, you can use the following:
>
> SELECT *, ( SELECT SUM( value) from table as t2 where t2.cod <= t1.cod)
> as running_total
> FROM table as t1
> ORDER BY cod;
>
> jll
>

Subqueries outside of the where clause are great! I hadn't come accross
them when working with the more well advertised database products.

Are they SQL9x compliant? I try to develop using non postgres specific
tools when I can.

Jim

In response to

  • Re: Sum at 2002-03-28 17:40:10 from Jean-Luc Lachance

Responses

  • Re: Sum at 2002-03-28 18:21:05 from Jean-Luc Lachance

Browse pgsql-general by date

  From Date Subject
Next Message Marcelo Pereira 2002-03-28 17:45:56 Re: Sum
Previous Message Jean-Luc Lachance 2002-03-28 17:40:10 Re: Sum