pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Penchalaiah P. <penchalaiahp@infics.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: hi
Date: Tue, 24 Apr 2007 09:41:26 -0700 (PDT)
Message-ID: <20070424092234.V55902@megazone.bigpanda.com> (raw)
In-Reply-To: <A70AE049E81A6A40879D5DC0AC8C38C908CD9133@venus.infics.com>
References: <A70AE049E81A6A40879D5DC0AC8C38C908CD9133@venus.infics.com>

On Tue, 24 Apr 2007, Penchalaiah P. wrote:

> Hi
>
> I have the data like this in temp table
>
> SQL> Select sno, value from temp;
>
> SNO                           Value
>
> 1                     650.00
>
> 2                     850.00
>
> 3                     640.00
>
> 3                     985.00
>
> 5                     987.00
>
> 9                     9864.00
>
> 7                     875.00

Tables are not ordered.  You'll need something like an ordering column
that represents the ordering and is unique.

Then you can probably do something like (untested):
 select sno, value, (select sum(value) as sum from temp t where t.ordering
 <= temp.ordering) from temp order by ordering;
or
 select t1.sno, t1.value, sum(t2.value) from temp as t1, temp as t2 where
 t1.ordering >= t2.ordering group by t1.ordering, t1.sno, t1.value order
 by t1.ordering;



view thread (18+ messages)  latest in thread

Message-ID: <20070424092234.V55902@megazone.bigpanda.com>
Permalink:  ../20070424092234.V55902@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20070424092234.V55902@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, penchalaiahp@infics.com
  Subject: Re: hi
  In-Reply-To: <20070424092234.V55902@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox