View Single Post

   
  #1 (permalink)  
Old 04-08-2008, 01:04 PM
pankaj_wolfhunter@yahoo.co.in
 
Posts: n/a
Default Running Update Problem

Greeting,

I have a table say t1 with structure as (dummy)

t1

id id1 id2
1 0 -1
2 0 -3
3 8 -4
4 0 -5


I want to:
update t1 set id1=min(id2) where id1=0.
but each id1 should get updated with one value greater than the
previous value.

Means, here the min(id2) is -5, so all id1=0 record should get updated
starting with -6, -7, -8 and so on.

Output like

id id1 id2
1 -6 -1
2 -7 -3
3 8 -4
4 -8 -5

Can anyone help me build this logic?

Help would be appreciated

TIA

Reply With Quote