Re: How to GROUP results BY month

From: "Oliveiros Cristina" <oliveiros(dot)cristina(at)marktest(dot)pt>
To: "Mark Roberts" <mailing_lists(at)pandapocket(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: How to GROUP results BY month
Date: 2008-07-17 11:18:18
Message-ID: 00b001c8e7fe$d09cb720$ec5a3d0a@marktestcr.marktest.pt
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

All,

Thanks a million for your help and thoughtful considerations.
>From this thread I learned lots.
As my concrete problem just concerns one year, I used the extract function,
but I ve mentally wrote down the date_trunc construct as suggested by
Herouth

Andreas and Scott, thanks for the tips on indexing

Again, thanks a lot.

Best,
Oliveiros

----- Original Message -----
From: "Mark Roberts" <mailing_lists(at)pandapocket(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Sent: Wednesday, July 16, 2008 5:29 PM
Subject: Re: [SQL] How to GROUP results BY month

>
> On Wed, 2008-07-16 at 07:39 +0200, A. Kretschmer wrote:
>> am Tue, dem 15.07.2008, um 18:15:07 -0700 mailte Mark Roberts
>> folgendes:
>> >
>> > On Tue, 2008-07-15 at 14:31 +0200, A. Kretschmer wrote:
>> > > am Tue, dem 15.07.2008, um 13:12:39 +0100 mailte Oliveiros
>> Cristina folgendes:
>> > > > 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?
>> > >
>> > > ... group by extract(month from date)
>> > >
>> > >
>> > > Andreas
>> >
>> > It's worth noting that extract(month from timestamp) returns a
>> month_no, and thus will not be suitable for grouping queries that span
>> years.
>>
>> Right, but that wasn't the question...
>
> Honestly, the way the question was phrased, I'd have assumed that it
> wanted to group by month (not group by a group of months). Jan 08 is
> distinct from Jan 07.
>
> Please accept my sincerest apologies if you you feel that I
> misinterpreted the question. I was merely trying to illustrate the
> difference between what each approach was.
>
> -Mark
>
>
> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Florian Weimer 2008-07-17 11:44:24 Re: Generating table rows from arrays
Previous Message Pavel Stehule 2008-07-17 10:38:41 Re: Generating table rows from arrays