The Hermit Hacker <scrappy@hub.org> writes:
> SELECT ( date_part('month', stat_period) || '/' ||
> date_part('day', stat_period) || '/' ||
> date_part('year', stat_period) || ' ' ||
> date_part('hour', stat_period) || ':00:00' ) as "Summary - by Day/Hour",
> sum(impressions) as impressions, sum(click_thru) as click_thru
> FROM banner_count
> GROUP BY "Summary - by Day/Hour"
> ORDER BY "Summary - by Day/Hour"::datetime;
Uh, why don't you just GROUP BY and ORDER BY stat_period?
I also wonder whether you can't find a combination of date_trunc and
datestyle that will produce the output format you want. Doing it
like the above sure seems like using the wrong tool for the job...
regards, tom lane