Re: duplicate dates

Поиск
Список
Период
Сортировка
От Jonathan Gardner
Тема Re: duplicate dates
Дата
Msg-id 200308080829.37711.jgardner@jonathangardner.net
обсуждение исходный текст
Ответ на duplicate dates  (Jodi Kanter <jkanter@virginia.edu>)
Список pgsql-sql
-----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-----


В списке pgsql-sql по дате отправления:

Предыдущее
От: BenLaKnet
Дата:
Сообщение: [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3
Следующее
От: Stephan Szabo
Дата:
Сообщение: Re: [pg-sql] - Problem with duplicate table (PostgreSQL 7.2.3