pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Viorel Dragomir <bigchief@vio.ro>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-sql@postgresql.org
Subject: Re: summing tables
Date: Tue, 15 Jul 2003 18:49:40 +0300
Message-ID: <016101c34ae8$b4277a20$0600a8c0@fix.ro> (raw)
References: <20030715140921.7c5a6a6c.erik@thiele-hydraulik.de>
	<001501c34aca$e70ca280$0600a8c0@fix.ro>
	<20030715143925.54716ed4.erik@thiele-hydraulik.de>
	<22671.1058282096@sss.pgh.pa.us>
	<012b01c34ae6$40ab0870$0600a8c0@fix.ro>
	<22931.1058283723@sss.pgh.pa.us>


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


> "Viorel Dragomir" <bigchief@vio.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
"




view thread (13+ messages)

Message-ID: <016101c34ae8$b4277a20$0600a8c0@fix.ro>
Permalink:  ../016101c34ae8$b4277a20$0600a8c0@fix.ro/
Also on:    postgresql.org/message-id/016101c34ae8$b4277a20$0600a8c0@fix.ro

 · 

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: bigchief@vio.ro, tgl@sss.pgh.pa.us
  Subject: Re: summing tables
  In-Reply-To: <016101c34ae8$b4277a20$0600a8c0@fix.ro>

* 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