Re: How to remove duplicate lines but save one of the lines?

From: Raymond O'Donnell <rod(at)iol(dot)ie>
To: A B <gentosaker(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: How to remove duplicate lines but save one of the lines?
Date: 2008-07-21 15:41:34
Message-ID: 4884AE2E.8060305@iol.ie
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 21/07/2008 16:33, A B wrote:
> I have a table with rows like this
> A 1
> A 1
> B 3
> B 3
> C 44
> C 44
> and so on.
>
> and I want it to be
> A 1
> B 3
> C 44
>
> so how can I remove the all the duplicate lines but one?

You could copy them into a new table, like so:

CREATE TABLE newtable AS
SELECT DISTINCT * FROM oldtable;

Ray.

------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod(at)iol(dot)ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Said Ramirez 2008-07-21 15:42:06 Re: How to remove duplicate lines but save one of the lines?
Previous Message A B 2008-07-21 15:33:59 How to remove duplicate lines but save one of the lines?