From: Bryce Nesbitt <bryce1@obviously.com>
To: pgsql-sql@postgresql.org
Subject: group by function, make SQL cleaner?
Date: Wed, 15 Mar 2006 21:18:40 -0800
Message-ID: <4418F52F.4070804@obviously.com> (raw)
I've got a working query:
stage=# SELECT date_trunc('day',endtime),count(*)
FROM eg_event where endtime >= '2006-02-01' and endtime < '2006-03-01'
GROUP BY date_trunc('day',endtime)
ORDER BY date_trunc('day',endtime);
date_trunc | count
---------------------+-------
2006-02-01 00:00:00 | 253
2006-02-02 00:00:00 | 245
2006-02-03 00:00:00 | 231
2006-02-04 00:00:00 | 313
2006-02-05 00:00:00 | 285
2006-02-06 00:00:00 | 194
2006-02-07 00:00:00 | 229
2006-02-08 00:00:00 | 239
2006-02-09 00:00:00 | 250
2006-02-10 00:00:00 | 245
2006-02-11 00:00:00 | 275
Is there a way to eliminate the ugly repeated use of
date_trunc('day',endtime)?
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 using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: bryce1@obviously.com
Subject: Re: group by function, make SQL cleaner?
In-Reply-To: <4418F52F.4070804@obviously.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