Re: summing tables

From: "Viorel Dragomir" <bigchief(at)vio(dot)ro>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: summing tables
Date: 2003-07-15 15:49:40
Message-ID: 016101c34ae8$b4277a20$0600a8c0@fix.ro
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


----- Original Message -----
From: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Viorel Dragomir" <bigchief(at)vio(dot)ro>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Tuesday, July 15, 2003 6:42 PM
Subject: Re: [SQL] summing tables

> "Viorel Dragomir" <bigchief(at)vio(dot)ro> writes:
> > Indeed it was a mistake not to put the table_name. in where clause.
> > But this doesn't resolve the problem.
>
> > Do you know in which order the update will modify the rows?
>
> No, and *it does not matter*. You are forgetting that this all runs
> under MVCC rules. The sub-SELECTs will see the pre-existing versions
> of the rows, whether or not the UPDATE has yet produced new versions.

Yes that was correct.
I forgot that the subselect sees only the old rows.

And the ORDER option will not make any difference, only making fool out of
myself. :)
I don't know if the problem is solved with my posted function.

Anyway this is the mail that started all [i get a lot of emails and i'm not
really searching for a solution on this matter]:
"
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
"

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message floyds 2003-07-15 16:13:56 column doesn't get calculated
Previous Message Tom Lane 2003-07-15 15:42:03 Re: summing tables