pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedgrouping by date increments
2+ messages / 2 participants
[nested] [flat]
* grouping by date increments
@ 2001-01-23 11:41 Graham Vickrage <graham@digitalplanit.com>
2001-01-23 16:19 ` Re: grouping by date increments Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 2+ messages in thread
From: Graham Vickrage @ 2001-01-23 11:41 UTC (permalink / raw)
To: pgsql-sql
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
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: grouping by date increments
2001-01-23 11:41 grouping by date increments Graham Vickrage <graham@digitalplanit.com>
@ 2001-01-23 16:19 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 2+ messages in thread
From: Tom Lane @ 2001-01-23 16:19 UTC (permalink / raw)
To: Graham Vickrage <graham@digitalplanit.com>; +Cc: pgsql-sql
"Graham Vickrage" <graham@digitalplanit.com> writes:
> I have written this successfully but need to get the count in time
> increments such as per day/week/month.
Perhaps use GROUP BY date_part(...). See
stgresql.org/devel-corner/docs/postgres/functions-datetime.htm
for doco on date_part().
regards, tom lane
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-01-23 16:19 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-01-23 11:41 grouping by date increments Graham Vickrage <graham@digitalplanit.com>
2001-01-23 16:19 ` Tom Lane <tgl@sss.pgh.pa.us>
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