From: Graham Vickrage <graham@digitalplanit.com>
To: pgsql-sql@postgresql.org
Subject: grouping by date increments
Date: Tue, 23 Jan 2001 11:41:40 -0000
Message-ID: <NDBBJABDILOPAOOMFJHOMECGCHAA.graham@digitalplanit.com> (raw)
I am trying to write a select statement to count the occurences of a
particular string between a set of dates.
I have written this successfully but need to get the count in time
increments such as per day/week/month.
At the moment I am doing a select for each increment seperately but figure
that as its doing a seqential scan then it may be possible to do it all at
once.
Has anyone done anything similar that or maybe could recommend a more
efficient solution.
Thanks
Graham
current select:
SELECT to_char(timestamp('01-Jun-2000'), 'DD-Mon-YYYY'),
to_char(timestamp('01-Aug-2000'), 'DD-Mon-YYYY'), count(*) FROM table WHERE
date >= timestamp('01-Jun-2000') AND date < timestamp('01-Aug-2000') AND
text = 'FOOBAR';
Attachments:
winmail.dat (application/ms-tnef, 1.8K) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: graham@digitalplanit.com
Subject: Re: grouping by date increments
In-Reply-To: <NDBBJABDILOPAOOMFJHOMECGCHAA.graham@digitalplanit.com>
References: <NDBBJABDILOPAOOMFJHOMECGCHAA.graham@digitalplanit.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox