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
 

 

Deleting n rows among m duplicated rows

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Deleting n rows among m duplicated rows
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: 6967
Location: porcelain throne

PostPosted: Mon Aug 04, 2008 5:47 pm    Post subject:
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

Site Director


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

PostPosted: Mon Aug 04, 2008 9:35 pm    Post subject:
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    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 To display values of multiple rows in... vinu78 DB2 2 Thu Mar 09, 2017 1:20 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
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 Row-Numbers of distinct rows? Auryn DB2 1 Thu Oct 20, 2016 4:38 pm


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