group by function, make SQL cleaner? - Mailing list pgsql-sql

From Bryce Nesbitt
Subject group by function, make SQL cleaner?
Date
Msg-id 4418F52F.4070804@obviously.com
Whole thread Raw
Responses Re: group by function, make SQL cleaner?
Re: group by function, make SQL cleaner?
Re: group by function, make SQL cleaner?
List 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 |   2532006-02-02 00:00:00 |   2452006-02-03 00:00:00 |
2312006-02-0400:00:00 |   3132006-02-05 00:00:00 |   2852006-02-06 00:00:00 |   1942006-02-07 00:00:00 |
2292006-02-0800:00:00 |   2392006-02-09 00:00:00 |   2502006-02-10 00:00:00 |   2452006-02-11 00:00:00 |   275
 

Is there a way to eliminate the ugly repeated use of
date_trunc('day',endtime)?



pgsql-sql by date:

Previous
From: Aarni Ruuhimäki
Date:
Subject: Re: Copying a row within table
Next
From: Tom Lane
Date:
Subject: Re: group by function, make SQL cleaner?