need a query to delete duplicate records from a table

IBM's flagship relational database management system
var111
Posts: 4
Joined: Tue Nov 04, 2008 11:31 am
Skillset: cobol, jcl, db2, cics, vsam
Referer: friends

need a query to delete duplicate records from a table

Postby var111 » Wed Nov 05, 2008 12:00 pm

Hi All,

I want to delete duplicates records from a table, suppose 4 records are duplicate then out of 4 3 we have to delete, can anyone give me that Query???

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: need a query to delete duplicate records from a table

Postby dick scherrer » Wed Nov 05, 2008 12:56 pm

Hello and welcome to the forum,

One way would be to unload the table (thereby creating a backup in case there are problems), remove the duplicates in batch using your sort product, then reload the non-duplicates back into the table.

You would also need to provide a clear definition of what constitutes a duplicate.
Hope this helps,
d.sch.

pooja katiyar
Posts: 2
Joined: Wed Nov 05, 2008 3:25 pm
Skillset: JCL,COBOL,CICS,DB2,VSAM
Referer: website

Re: need a query to delete duplicate records from a table

Postby pooja katiyar » Wed Nov 05, 2008 4:30 pm

U can use" DISTINCT" to remove duplicacy

User avatar
dick scherrer
Global moderator
Posts: 6268
Joined: Sat Jun 09, 2007 8:58 am

Re: need a query to delete duplicate records from a table

Postby dick scherrer » Wed Nov 05, 2008 9:52 pm

Hello,

U can use" DISTINCT" to remove duplicacy
Please post the query that will delete duplicates from a table using distinct. . .
Hope this helps,
d.sch.

var111
Posts: 4
Joined: Tue Nov 04, 2008 11:31 am
Skillset: cobol, jcl, db2, cics, vsam
Referer: friends

Re: need a query to delete duplicate records from a table

Postby var111 » Fri Nov 07, 2008 4:13 pm

Hi Pooja,

Distinct is not going to update any thing, it only shows the non duplicate records without updating the table.


  • Similar Topics
    Replies
    Views
    Last post