Re: How to GROUP results BY month

From: Herouth Maoz <herouth(at)unicell(dot)co(dot)il>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to GROUP results BY month
Date: 2008-07-15 12:32:15
Message-ID: 487C98CF.7060202@unicell.co.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Oliveiros Cristina 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?
Yes, use date_trunc( 'month', time_stamp ).

Example:

select count(*),date_trunc( 'month', time_stamp ) from rb group by
date_trunc( 'month', time_stamp );

Herouth

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Herouth Maoz 2008-07-15 12:39:54 Re: How to GROUP results BY month
Previous Message A. Kretschmer 2008-07-15 12:31:57 Re: How to GROUP results BY month