View previous topic :: View next topic
|
Author |
Message |
maheshvamsi
New User
Joined: 22 Mar 2008 Posts: 39 Location: bangalore
|
|
|
|
Hi,
by using spufi can we update a column duplicate rows by keeping one row unchanged.
Table:
Code: |
col1 col2 col3
a b 1
a b 1
c d 2
c d 2 |
Based in col1 & col2 update col3
Output:
Code: |
col1 col2 col3
a b 1
a b 0
c d 2
c d 0 |
|
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
How/why is this a spufi question?
If you can define the "rules" you should be able to write the needed sql. . .
What has been posted is too limited a sample to establish "rules" (at least for me). |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
db2 V9:
Code: |
update table1 B set col3 = 0
where rid(B) not in (select min(rid(A)) from table1 A group by col1,col2,col3) |
|
|
Back to top |
|
|
maheshvamsi
New User
Joined: 22 Mar 2008 Posts: 39 Location: bangalore
|
|
|
|
Hi Dick,
Its not a question about spufi, I want to know whether we can update the table using one querry instead of writing a program.
Thank you GuyC, for providing the solution.
|
|
Back to top |
|
|
|