pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jonathan Gardner <jgardner@jonathangardner.net>
To: Jodi Kanter <jkanter@virginia.edu>
To: Postgres SQL List <pgsql-sql@postgresql.org>
Subject: Re: duplicate dates
Date: Fri, 8 Aug 2003 08:29:36 -0700
Message-ID: <200308080829.37711.jgardner@jonathangardner.net> (raw)
In-Reply-To: <3F2A8DAE.4060003@virginia.edu>
References: <3F2A8DAE.4060003@virginia.edu>

-----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 
by. Note that date_part can give you interesting groupings (all the 
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 the 
from clause. You could also save the results in a temp table.

- -- 
Jonathan Gardner <jgardner@jonathangardner.net>
Live Free, Use Linux!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iD8DBQE/M8HgWgwF3QvpWNwRAsUNAKCLnB6vajJ8fuS7IRgp0pYxp6YaxgCg2qbk
juL5a4tM1la0zmP81PdxS/c=
=N8Q/
-----END PGP SIGNATURE-----



view thread (3+ messages)

Message-ID: <200308080829.37711.jgardner@jonathangardner.net>
Permalink:  ../200308080829.37711.jgardner@jonathangardner.net/
Also on:    postgresql.org/message-id/200308080829.37711.jgardner@jonathangardner.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jgardner@jonathangardner.net, jkanter@virginia.edu
  Subject: Re: duplicate dates
  In-Reply-To: <200308080829.37711.jgardner@jonathangardner.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox