Re: How to delete duplicated records ?

From: Jan-Marcel <jan-marcel_at_wau.mis.ah.nl>
Date: 1998/11/24
Message-ID: <F2x19B.n8s_at_ahisinfr.xs4all.nl>#1/1


Actually this is quit simple.

Your statement should be something like:

delete from table tab1
where tab1.id not in (select min(tab2.id)

                                    from table tab2
                                    where tab2.value1 = tab1.value1
                                    and   tab2.value2 = tab1.value2)

When you need to save the duplicate records with the highest id's, change 'min' into 'max' in the statement above.

Good luck,

Jan-Marcel

Danil Krasnov heeft geschreven in bericht <01be16f1$5106c480$168480c3_at_www>...
>
>Hello, Gurus !
>
>There are duplicated records have been appeared in the table... reason is
>not clear, but its not a topic..
>I have to delete duplicated records...
>
>Example:
>
>Table A:
>
>Id Value1 Value2
>
> 1 111 222
> 2 111 222
> 3 111 222
> 4 333 444
> 5 333 444
>
>The task - is to delete rows with id's 2, 3, 5...
>
>Any suggestions?
>
>Thanks in advance..
>
>------------
>Danil Kranov
>danil_at_maginfo.net
Received on Tue Nov 24 1998 - 00:00:00 CET

Original text of this message