Re: Delete duplicates

From: Ian Barwick <barwick(at)gmx(dot)net>
To: "Rudi Starcevic" <rudi(at)oasis(dot)net(dot)au>, pgsql-sql(at)postgresql(dot)org
Subject: Re: Delete duplicates
Date: 2003-06-22 10:20:15
Message-ID: 200306221220.15480.barwick@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Sunday 22 June 2003 11:15, Rudi Starcevic wrote:
> Hi,
>
> I have a table with duplicates and trouble with my SQL.

(...)

> select a1.id
> from aap a1
> where id < ( SELECT max(id) FROM aap AS a2 )
> AND EXISTS
> (
> SELECT *
> FROM aap AS a2
> WHERE a1.keyword = a2.keyword
> )

How about (untested):

SELECT a1.id
FROM aap a1
WHERE id = (SELECT MAX(id) FROM aap a2
WHERE a2.keyword = a1.keyword)

Ian Barwick
barwick(at)gmx(dot)net

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Paul Thomas 2003-06-22 11:03:35 Re: Delete duplicates
Previous Message Rudi Starcevic 2003-06-22 09:15:22 Delete duplicates