Re: How to GROUP results BY month

Поиск
Список
Период
Сортировка
От A. Kretschmer
Тема Re: How to GROUP results BY month
Дата
Msg-id 20080716053747.GB2323@a-kretschmer.de
обсуждение исходный текст
Ответ на Re: How to GROUP results BY month  ("Scott Marlowe" <scott.marlowe@gmail.com>)
Список pgsql-sql
am  Tue, dem 15.07.2008, um 15:57:54 -0600 mailte Scott Marlowe folgendes:
> On Tue, Jul 15, 2008 at 6:12 AM, Oliveiros Cristina
> <oliveiros.cristina@marktest.pt> wrote:
> > Howdy, all,
> >
> > I have a problem.
> >
> > I have a table which one of the fields is of type date.
> >
> > I need to obtain the totals of the other fields in a  by-month basis
> > IS there any easy way to do this using the GROUP BY or any other construct?
> >
> 
> In addition to the responses on grouping by extract('month' from
> timestamp) you can also index on this function as long as timestamp
> isn't timestamp with timezone.  With that index in place, grouping by

You can also create an index on an timestamptz column for a particular
time zone ;-)

test=*# create table foo (ts timestamptz);
CREATE TABLE
test=*# create index foo_idx on foo(extract(month from ts at time zone 'GMT'));
CREATE INDEX


Andreas
-- 
Andreas Kretschmer
Kontakt:  Heynitz: 035242/47150,   D1: 0160/7141639 (mehr: -> Header)
GnuPG-ID:   0x3FFF606C, privat 0x7F4584DA   http://wwwkeys.de.pgp.net


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

Предыдущее
От: Decibel!
Дата:
Сообщение: Re: COPY equivalent for updates
Следующее
От: "A. Kretschmer"
Дата:
Сообщение: Re: How to GROUP results BY month