From: | Jean-Luc Lachance <jllachan(at)nsd(dot)ca> |
---|---|
To: | Jim Martinez <jjm(at)bigbigorg(dot)org> |
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 18:21:05 |
Message-ID: | 3CA35F11.852DEADF@nsd.ca |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Maybe our resident expert on SQL standard, Tom Lane, would care to
answer this one.
Jim Martinez wrote:
>
> 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
From | Date | Subject | |
---|---|---|---|
Next Message | Davi Leal | 2002-03-28 18:24:57 | NOTIFY tableX, LISTEN tableX, pool Nofities() |
Previous Message | Riebs, Andy | 2002-03-28 18:09:44 | Re: Performance Tuning Document? |