Received: from candle.pha.pa.us (pgman@s5-03.ppp.op.net [209.152.195.67]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA24756 for ; Tue, 18 Jan 2000 13:29:15 -0500 (EST) (envelope-from pgman@candle.pha.pa.us) Received: (from pgman@localhost) by candle.pha.pa.us (8.9.0/8.9.0) id NAA05364; Tue, 18 Jan 2000 13:28:40 -0500 (EST) From: Bruce Momjian Message-Id: <200001181828.NAA05364@candle.pha.pa.us> Subject: Re: [SQL] Ordering a date_part() query ... In-Reply-To: <3884A6BE.41B2C9CB@epamail.epa.gov> from Mark Volpe at "Jan 18, 2000 12:45:34 pm" To: Mark Volpe Date: Tue, 18 Jan 2000 13:28:40 -0500 (EST) CC: The Hermit Hacker , pgsql-sql@postgreSQL.org X-Mailer: ELM [version 2.4ME+ PL66 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit > The Hermit Hacker wrote: > > > > I have a query that looks like: > > > > 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"; > > > > Try appending ORDER BY "Summary - by Day/Hour"::date > to your query. Oh, much better than my CASE idea. I thought he was sorting date/time strings, not datetime values. -- Bruce Momjian | http://www.op.net/~candle pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026