X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id AE62ED1C9CF for ; Fri, 1 Aug 2003 15:57:46 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 51804-10 for ; Fri, 1 Aug 2003 12:56:38 -0300 (ADT) Received: from mail.libertyrms.com (unknown [209.167.124.227]) by svr1.postgresql.org (Postfix) with ESMTP id B160BD1C9C9 for ; Fri, 1 Aug 2003 12:57:44 -0300 (ADT) Received: from dev6.int.libertyrms.com ([10.1.2.212] helo=libertyrms.info) by mail.libertyrms.com with esmtp (Exim 3.22 #3 (Debian)) id 19icHo-0007kE-00; Fri, 01 Aug 2003 11:57:44 -0400 Received: by libertyrms.info (Postfix, from userid 1079) id 5EC42BBAD8; Fri, 1 Aug 2003 11:57:44 -0400 (EDT) To: Jodi Kanter Cc: Postgres SQL List Subject: Re: duplicate dates From: Christopher Browne Date: Fri, 01 Aug 2003 11:57:44 -0400 Message-ID: <60oez9l69z.fsf@dev6.int.libertyrms.info> User-Agent: Gnus/5.1003 (Gnus v5.10.3) XEmacs/21.4 (Rational FORTRAN, linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/5 X-Sequence-Number: 14621 Jodi Kanter wrote: > I have one table that has a date/time field in it. I'd like to identify > the records in the database where the date/time fields are the same. How > can I do this? Do I need to create a view or temp table? Is there a way > to run through one table multiple times. If you plan to review the data multiple times, and the table is rather large, then it probably makes sense to make a temp table. select a.* into temp table my_dupes from dated_table a, dated_table b where a.event_on = b.event_on -- Assuming that the primary key is on (field1, field2, field3) and a.key_field1 <> b.key_field1 and a.key_field2 <> b.key_field2 and a.key_field3 <> b.key_field3; You could then rummage through my_dupes as needed. Note that if there are more than 2 simultaneous records, it will list all of them multiple times :-(. You may also want to be more precise about what you mean by 'date/time fields are the same'. They go down to fractions of a second, so you shouldn't have a huge number of collisions. -- output = ("cbbrowne" "@" "libertyrms.info") Christopher Browne (416) 646 3304 x124 (land)