how to remove the duplicate records from a table

From: Yi Zhao <yi(dot)zhao(at)alibaba-inc(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: how to remove the duplicate records from a table
Date: 2008-10-07 06:36:59
Message-ID: 1223361419.3769.6.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a table contains some duplicate records, and this table create
without oids, for example:
id | temp_id
----+---------
10 | 1
10 | 1
10 | 1
20 | 4
20 | 4
30 | 5
30 | 5
I want get the duplicated records removed and only one is reserved, so
the results is:
10 1
20 4
30 5

I know create a temp table will resolve this problem, but I don't want
this way:)

can someone tell me a simple methold?

any help is appreciated,

thanks,

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Henry Combrinck 2008-10-07 06:50:18 Re: Looping through cursor row batches
Previous Message Greg Smith 2008-10-07 04:11:11 Re: Installation on CentOS 5.2 (readline trouble)