Re: Deletion of duplicate rows in a table
Posted in 1996
Topics: SQL Development & Query Writing
>
>
> Hi !
>
> can somebody tell me how to delete duplicate rows from a table using a single
> query in Informix. Is it possible in Ansi-Sql ?
>
> I tried using the following query but it is giving a syntax error :
>
> delete from table
> where ( select column 1, column 2
> from table
> group by column 1, column 2
> having count(*) > 1 )>
> Appreciate your response
>
> - Kishore
>
>
Hi Kishore ,
In the above query , u have not specified the condition for a
particular field . If u change the query as follws it should work ...
delete from table
where 1 != ( select count(*)
from table
group by column 1, column 2
having count(*) > 1 )
Note : having clause is not needed here .
..... Have a nice time ....
Bye.
Peter.
\\|||/
( O-O )
*-----------------*-----------*--------.ooo0--(_)-0ooo.--------*--------*
Residence : Office :
2409 Otb Appartements Siemens Nixdorf
Ottobrunner str 92 Informationsysteme AG
81737 Munich Office Automation Business Unit
Germany Otto-Hahn-Ring 6
81739 Munich
Germany
Ph : 49-89-6800062409/ Ph : 49-89-4144-7114
49-89-6800060 Extn 2409
e-mail : mpeter.muc@sni.de .oooO
( ) Oooo.
*-----------------*-----------*------------\\ (----( )---------*--------*
\\_) ) /
(_/