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 3EA29D1C983 for ; Fri, 8 Aug 2003 15:29:50 +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 43541-03 for ; Fri, 8 Aug 2003 12:28:21 -0300 (ADT) Received: from irko.smoothcorp.com (unknown [208.49.241.41]) by svr1.postgresql.org (Postfix) with ESMTP id 5C990D1C4E1 for ; Fri, 8 Aug 2003 12:29:39 -0300 (ADT) Received: from [10.0.1.63] (helo=jgardner.smoothcorp.com) by irko.smoothcorp.com with esmtp (Exim 4.12) id 19l9BR-0004sW-00; Fri, 08 Aug 2003 08:29:37 -0700 Received: from jgardner.smoothcorp.com (localhost.localdomain [127.0.0.1]) by jgardner.smoothcorp.com (8.12.8/8.12.8) with ESMTP id h78FTcsN026107; Fri, 8 Aug 2003 08:29:38 -0700 Received: from localhost (localhost [[UNIX: localhost]]) by jgardner.smoothcorp.com (8.12.8/8.12.8/Submit) id h78FTc5A026105; Fri, 8 Aug 2003 08:29:38 -0700 From: Jonathan Gardner To: Jodi Kanter , Postgres SQL List Subject: Re: duplicate dates Date: Fri, 8 Aug 2003 08:29:36 -0700 User-Agent: KMail/1.5 References: <3F2A8DAE.4060003@virginia.edu> In-Reply-To: <3F2A8DAE.4060003@virginia.edu> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Content-Description: clearsigned data Content-Disposition: inline Message-Id: <200308080829.37711.jgardner@jonathangardner.net> X-SA-Exim-Rcpt-To: jkanter@virginia.edu, pgsql-sql@postgresql.org X-SA-Exim-Scanned: No; SAEximRunCond expanded to false X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200308/70 X-Sequence-Number: 14686 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Friday 01 August 2003 08:56, 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. SELECT date_trunc('month', date_column), ... GROUP BY date_trunc('month', date_column) HAVING count(primary_key) > 1; Replace date_trunc('month', date_column) with whatever you want to group it= =20 by. Note that date_part can give you interesting groupings (all the=20 Decembers, all the 1st of the months, all the Fridays, etc...) If you want to run through it several times, you can have a sub-select in t= he=20 from clause. You could also save the results in a temp table. - --=20 Jonathan Gardner Live Free, Use Linux! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (GNU/Linux) iD8DBQE/M8HgWgwF3QvpWNwRAsUNAKCLnB6vajJ8fuS7IRgp0pYxp6YaxgCg2qbk juL5a4tM1la0zmP81PdxS/c=3D =3DN8Q/ -----END PGP SIGNATURE-----