Re: hi

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: "Penchalaiah P(dot)" <penchalaiahp(at)infics(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: hi
Date: 2007-04-24 16:41:26
Message-ID: 20070424092234.V55902@megazone.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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;

In response to

  • hi at 2007-04-24 12:09:05 from Penchalaiah P.

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-04-24 16:42:58 Re: How does server handle clients that disconnect ungracefully?
Previous Message Albe Laurenz 2007-04-24 16:15:00 Re: pgsql-general@postgresql.org

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Albright 2007-04-24 20:42:01 plpgsql array looping
Previous Message Richard Huxton 2007-04-24 15:52:52 Re: Function to return a multiple colmn table or view