Re: Removing duplicate rows in table

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Rich Shepard <rshepard(at)appl-ecosys(dot)com>, pgsql-general(at)postgresql(dot)org
Subject: Re: Removing duplicate rows in table
Date: 2024-09-10 15:22:36
Message-ID: 32765388-836c-4c00-bad0-665f0aa77ea8@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 9/10/24 08:07, Rich Shepard wrote:
> I've no idea how I entered multiple, identical rows in a table but I
> want to
> delete all but one of these rows.

Is there a Primary Key or Unique index on this table?

>
> Here's an example:
>
> bustrac=# select * from projects where proj_nbr = '4242.01';
>  proj_nbr |   proj_name    | start_date |  end_date  |  description  |
> notes
> ----------+----------------+------------+------------+---------------+-------
>  4242.01  | Expert witness | 2008-10-15 | 2008-10-28 | Consol Energy |
>  4242.01  | Expert witness | 2008-10-15 | 2008-10-28 | Consol Energy |
>  4242.01  | Expert witness | 2008-10-15 | 2008-10-28 | Consol Energy |
>  4242.01  | Expert witness | 2008-10-15 | 2008-10-28 | Consol Energy |
> (4 rows)
>
> How do I clean this up so there's only a single row for this project
> number?
>
> TIA,
>
> Rich
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Andreas Kretschmer 2024-09-10 15:28:15 Re: Removing duplicate rows in table
Previous Message Ron Johnson 2024-09-10 15:16:15 Re: Removing duplicate rows in table