IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Deleting n rows among m duplicated rows


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sailaja.sn

New User


Joined: 14 Jul 2008
Posts: 4
Location: Chennai

PostPosted: Mon Aug 04, 2008 5:38 pm
Reply with quote

Hi,

My table contains some m duplicate rows . My requirement is to delete only n rows among those m duplicated rows.

To be more clear, please see the sample data:

TableA:
===============
ID Name Garde
==================
1 aaaa a1
1 aaaa a1
1 aaaa a1
2 bbbb b1

If we have used "delete from table where name = 'aaaa' " then it will delete all the rows with 'aaaa'.But my requirement is to keep a single row with 'aaaa' and delete all the other 2 'aaaa' rows that are duplicated.

Is there any way in resolving this issue.

Thanks & regards,
Sailaja
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Mon Aug 04, 2008 5:47 pm
Reply with quote

unload the table, process the qsam file, reload the table.
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


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

PostPosted: Mon Aug 04, 2008 9:35 pm
Reply with quote

Hello,

You might declare a cursor, fetch the "first" aaaa row and ignore it, fetch the others (if any) and delete them.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To get the count of rows for every 1 ... DB2 3
No new posts Exclude rows with > than x occurre... DFSORT/ICETOOL 6
No new posts Deleting a Tape file JCL & VSAM 14
No new posts CA7 deleting files in steps after job... CA Products 4
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
Search our Forums:

Back to Top