summing tables

From: Erik Thiele <erik(at)thiele-hydraulik(dot)de>
To: pgsql-sql(at)postgresql(dot)org
Subject: summing tables
Date: 2003-07-15 12:09:21
Message-ID: 20030715140921.7c5a6a6c.erik@thiele-hydraulik.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

hi,

i have a table consisting of 4 integers.

seq is for making the table ordered. (ORDER BY SEQ ASC)
a,b,c maybe null

seq | a | b | c
-----+----+----+---
0 | 1 | 2 | 3
1 | 1 | 2 |
2 | 5 | 7 |
3 | -2 | -4 |

i am needing a sql statement to do

c=a+b+"the c of the row with seq one less than myself"

this statement has to run over the whole table, in seq order.

how can this be acomplished???

cu&thanks
erik

--
Erik Thiele

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Viorel Dragomir 2003-07-15 12:16:21 Re: summing tables
Previous Message Benoît Bournon 2003-07-15 06:42:14 Re: Recursive request ...