Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Can we update duplicate rows in a spufi by keeping any row

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
maheshvamsi

New User


Joined: 22 Mar 2008
Posts: 39
Location: bangalore

PostPosted: Wed Jul 06, 2011 10:51 pm    Post subject: Can we update duplicate rows in a spufi by keeping any row
Reply with quote

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
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Wed Jul 06, 2011 11:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Jul 07, 2011 3:21 pm    Post subject:
Reply with quote

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
View user's profile Send private message
maheshvamsi

New User


Joined: 22 Mar 2008
Posts: 39
Location: bangalore

PostPosted: Thu Jul 07, 2011 5:42 pm    Post subject:
Reply with quote

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.

icon_smile.gif
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts Limit duplicate records in the SORT pshongal SYNCSORT 6 Mon Nov 21, 2016 12:54 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
No new posts How to update a portion of text in a ... Bill Woodger DFSORT/ICETOOL 25 Wed Nov 09, 2016 9:41 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us