need a query to delete duplicate records from a table



IBM's flagship relational database management system

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???
var111
 
Posts: 4
Joined: Tue Nov 04, 2008 11:31 am
Has thanked: 0 time
Been thanked: 0 time

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

 

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.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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
pooja katiyar
 
Posts: 2
Joined: Wed Nov 05, 2008 3:25 pm
Has thanked: 0 time
Been thanked: 0 time

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.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

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.
var111
 
Posts: 4
Joined: Tue Nov 04, 2008 11:31 am
Has thanked: 0 time
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post