Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id RAA92834 for ; Tue, 18 Jan 2000 17:26:42 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id RAA02231; Tue, 18 Jan 2000 17:26:37 -0500 (EST) To: The Hermit Hacker cc: pgsql-sql@postgreSQL.org Subject: Re: [SQL] Ordering a date_part() query ... In-reply-to: References: Comments: In-reply-to The Hermit Hacker message dated "Tue, 18 Jan 2000 17:06:38 -0400" Date: Tue, 18 Jan 2000 17:26:37 -0500 Message-ID: <2228.948234397@sss.pgh.pa.us> From: Tom Lane The Hermit Hacker writes: >> Uh, why don't you just GROUP BY and ORDER BY stat_period? > Okay, maybe I'm misunderstanding GROUP BY, but my understanding is that it > groups "like" values ... my above example would give me a count of all > impressions received over a one hour period ... Oh, so "stat_period" is not a period label but an exact timestamp, and you want to group into hourly blocks? OK, then group/order by date_trunc("hour", stat_period) is probably what you want... I'd suggest choosing another name for the field, too ;-) regards, tom lane