Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1so2WE-007qLb-Eg for pgsql-general@arkaria.postgresql.org; Tue, 10 Sep 2024 15:11:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1so2WE-00ETm4-6G for pgsql-general@arkaria.postgresql.org; Tue, 10 Sep 2024 15:11:02 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1so2WD-00ETjU-Ql for pgsql-general@lists.postgresql.org; Tue, 10 Sep 2024 15:11:01 +0000 Received: from smtp110.ord1d.emailsrvr.com ([184.106.54.110]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1so2WA-000UJh-6h for pgsql-general@postgresql.org; Tue, 10 Sep 2024 15:11:01 +0000 X-Auth-ID: xof@thebuild.com Received: by smtp14.relay.ord1d.emailsrvr.com (Authenticated sender: xof-AT-thebuild.com) with ESMTPSA id 4D08E40165; Tue, 10 Sep 2024 11:10:57 -0400 (EDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: Removing duplicate rows in table From: Christophe Pettus In-Reply-To: Date: Tue, 10 Sep 2024 08:10:26 -0700 Cc: pgsql-general@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <2E60FD03-E5D9-42D6-A080-690A378AF862@thebuild.com> References: To: Rich Shepard X-Mailer: Apple Mail (2.3774.600.62) X-Classification-ID: c2879f96-6a34-4830-92c7-d1a773dd3746-1-1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk If you don't mind taking the time to swap tables, you can always do an = INSERT ... SELECT DISTINCT into a new table, and then swap it = with the existing table. > On Sep 10, 2024, at 08:07, Rich Shepard = wrote: >=20 > I've no idea how I entered multiple, identical rows in a table but I = want to > delete all but one of these rows. >=20 > Here's an example: >=20 > bustrac=3D# select * from projects where proj_nbr =3D '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) >=20 > How do I clean this up so there's only a single row for this project = number? >=20 > TIA, >=20 > Rich >=20 >=20