From: Tom Lane <tgl@sss.pgh.pa.us>
To: The Hermit Hacker <scrappy@hub.org>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Ordering a date_part() query ...
Date: Tue, 18 Jan 2000 14:45:10 -0500
Message-ID: <1318.948224710@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org>
References: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, scrappy@hub.org
Subject: Re: [SQL] Ordering a date_part() query ...
In-Reply-To: <1318.948224710@sss.pgh.pa.us>
References: <Pine.BSF.4.21.0001181511250.23487-100000@thelab.hub.org> <1318.948224710@sss.pgh.pa.us>
* 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