Re: Grouping by date range

Поиск
Список
Период
Сортировка
От Alexander Litvinov
Тема Re: Grouping by date range
Дата
Msg-id 200308191456.48517.lan@ac-sw.com
обсуждение исходный текст
Ответ на Grouping by date range  (Mat <psql-mail@freeuk.com>)
Ответы Re: Grouping by date range  (Ron Johnson <ron.l.johnson@cox.net>)
Re: Grouping by date range  (Jeffrey Melloy <jmelloy@visualdistortion.org>)
Список pgsql-general
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I home your date field have date type. If it is try this:

select date_part('year', date), count(*) from your_table group by
date_part('year', date) order by date_part('year', date);

for month add grouping by date_part('month', date)

if you need to handle large number of rows try to add columns with year and
month, write triggers for filling this columns, make indexes and things
should be fast.

> date    | data
> ---------------
> 01/01/01| 123
> 01/01/01| abc
> 02/01/01| def
> 03/03/01| hij
>
> I can see how to group by day - but how do i go about decreasing the
> precision down to months/years.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (GNU/Linux)

iD8DBQE/QdhAV+WKOINIfOYRAhT6AJ42zbMyux2CLLJh1XvAtYBrJhkhNwCfZXH5
AQH6c+qKqwbFZT3yNdTcm5I=
=tmYH
-----END PGP SIGNATURE-----


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

Предыдущее
От: Mike Mascari
Дата:
Сообщение: Re: Grouping by date range
Следующее
От: Francois Suter
Дата:
Сообщение: Mailing list in French