Re: Count rows group by time intervals

From: Kevin Hunter <hunteke(at)earlham(dot)edu>
To: Loredana Curugiu <loredana(dot)curugiu(at)gmail(dot)com>
Cc: PostgreSQL Novice List <pgsql-novice(at)postgresql(dot)org>
Subject: Re: Count rows group by time intervals
Date: 2007-05-09 13:39:21
Message-ID: 58BD097B-42B3-49D4-96DA-D7805F077C91@earlham.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

At 8:07a -0400 on 09 May 2007, Loredana Curugiu wrote:
> I have the following table:
>
> theme | receiver | date
> ---------+----------------------+------------------------
> LIA | +40741775622 | 2007-04-27 00:00:00+00
> LIA | +40741775622 | 2007-04-25 00:00:00+00
> MIA | +40741775622 | 2007-04-27 00:00:00+00
> MIA | +40741775622 | 2007-05-09 00:00:00+00
>
> I would like to count rows group by theme, receiver, and time
> intervals of
> two days. I don't know how to start.

Should get you started:

SELECT
COUNT( * ),
theme,
receiver,
date
FROM
yourTable
GROUP BY
theme,
receiver,
date
;

Kevin

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Oliveiros Cristina 2007-05-09 13:44:17 Re: Count rows group by time intervals
Previous Message Loredana Curugiu 2007-05-09 12:07:37 Count rows group by time intervals