| From: | Bryce Nesbitt <bryce1(at)obviously(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | group by function, make SQL cleaner? |
| Date: | 2006-03-16 05:18:40 |
| Message-ID: | 4418F52F.4070804@obviously.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
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)?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tom Lane | 2006-03-16 06:04:58 | Re: group by function, make SQL cleaner? |
| Previous Message | Aarni Ruuhimäki | 2006-03-15 08:35:27 | Re: Copying a row within table |