Re: hi
От | Stephan Szabo |
---|---|
Тема | Re: hi |
Дата | |
Msg-id | 20070424092234.V55902@megazone.bigpanda.com обсуждение исходный текст |
Ответ на | hi ("Penchalaiah P." <penchalaiahp@infics.com>) |
Список | 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; orselect t1.sno, t1.value, sum(t2.value) from temp as t1, temp as t2 wheret1.ordering >= t2.ordering group by t1.ordering,t1.sno, t1.value orderby t1.ordering;
В списке pgsql-sql по дате отправления: