Skip site navigation (1) Skip section navigation (2)

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:39:54
Message-ID: 487C9A9A.1040107@unicell.co.il (view raw or flat)
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

pgsql-sql by date

Next:From: Jonah H. HarrisDate: 2008-07-15 13:59:22
Subject: Re: Rollback in Postgres
Previous:From: Herouth MaozDate: 2008-07-15 12:32:15
Subject: Re: How to GROUP results BY month

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group