Re: Removing duplicate rows in table - Mailing list pgsql-general

From Ron Johnson
Subject Re: Removing duplicate rows in table
Date
Msg-id CANzqJaDetd_6G0cdj-oivxXet3bwk_NFm96=B9s7RMWjXo9VAA@mail.gmail.com
Whole thread Raw
In response to Removing duplicate rows in table  (Rich Shepard <rshepard@appl-ecosys.com>)
List pgsql-general
On Tue, Sep 10, 2024 at 11:07 AM Rich Shepard <rshepard@appl-ecosys.com> 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.

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?

 
I'd use row_number to delete records where row_number > 1.

--
Death to America, and butter sauce.
Iraq lobster!

pgsql-general by date:

Previous
From: Christophe Pettus
Date:
Subject: Re: Removing duplicate rows in table
Next
From: Adrian Klaver
Date:
Subject: Re: Removing duplicate rows in table