Re: How to GROUP results BY month - Mailing list pgsql-sql

From Scott Marlowe
Subject Re: How to GROUP results BY month
Date
Msg-id dcc563d10807151457o43c97aa7mc234a02cb37abb73@mail.gmail.com
Whole thread Raw
In response to How to GROUP results BY month  ("Oliveiros Cristina" <oliveiros.cristina@marktest.pt>)
Responses Re: How to GROUP results BY month
List pgsql-sql
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
month can be pretty fast even for large datasets covering many months.


pgsql-sql by date:

Previous
From: "Jonah H. Harris"
Date:
Subject: Re: Rollback in Postgres
Next
From: Mark Roberts
Date:
Subject: Re: How to GROUP results BY month