Removing duplicate rows in table

From: Rich Shepard <rshepard(at)appl-ecosys(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Removing duplicate rows in table
Date: 2024-09-10 15:07:04
Message-ID: e4688faf-de51-93ef-2db-f2acacbd658@appl-ecosys.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I've no idea how I entered multiple, identical rows in a table but I want to
delete all but one of these rows.

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Christophe Pettus 2024-09-10 15:10:26 Re: Removing duplicate rows in table
Previous Message Adrian Klaver 2024-09-10 14:57:40 Re: infinite loop in an update statement