X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0F797D1DC01 for ; Sun, 15 Feb 2004 20:01:34 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 74308-03 for ; Sun, 15 Feb 2004 16:01:34 -0400 (AST) Received: from srvr3.iniquinet.com (srvr2.iniquinet.com [64.240.87.12]) by svr1.postgresql.org (Postfix) with SMTP id AD545D1DC36 for ; Sun, 15 Feb 2004 16:01:31 -0400 (AST) Received: (qmail 17894 invoked by uid 104); 15 Feb 2004 19:47:08 -0000 Received: from Robert_Creager@LogicalChaos.org by srvr3.iniquinet.com by uid 101 with qmail-scanner-1.15 (clamscan: 0.65. spamassassin: 2.55. Clear:SA:0(-7.8/6.0):. Processed in 36.1206 secs); 15 Feb 2004 19:47:08 -0000 Received: from vsat-148-64-8-86.c119.t7.mrt.starband.net (HELO chaos.mshome.net) (148.64.8.86) by srvr3.iniquinet.com with SMTP; 15 Feb 2004 19:46:32 -0000 Received: from localhost.localdomain (thunder.mshome.net [192.168.0.250]) by chaos.mshome.net (Postfix) with ESMTP id 040451E50B5; Sun, 15 Feb 2004 13:00:38 -0700 (MST) Received: from logicalchaos.org (thunder.mshome.net [192.168.0.250]) by chaos.mshome.net (Postfix) with SMTP id E1B361E50B5; Sun, 15 Feb 2004 13:00:31 -0700 (MST) Date: Sun, 15 Feb 2004 13:00:25 -0700 From: Robert Creager To: stermic@gw.co.jackson.mo.us (Michael Sterling) Cc: pgsql-sql@postgresql.org Subject: Re: max timestamp Message-Id: <20040215130025.4e74ebf1.Robert_Creager@LogicalChaos.org> In-Reply-To: References: Organization: Starlight Vision, LLC. X-Mailer: Sylpheed version 0.9.5claws (GTK+ 1.2.10; i586-mandrake-linux-gnu) Mime-Version: 1.0 Content-Type: multipart/signed; protocol="application/pgp-signature"; micalg="pgp-sha1"; boundary="Multipart_Sun__15_Feb_2004_13_00_25_-0700_=.9v9EXutjLmb9oy" USER_IN_WHITELIST autolearn=ham version=2.63 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/182 X-Sequence-Number: 16872 --Multipart_Sun__15_Feb_2004_13_00_25_-0700_=.9v9EXutjLmb9oy Content-Type: text/plain; charset=US-ASCII Content-Disposition: inline Content-Transfer-Encoding: 7bit When grilled further on (10 Feb 2004 10:14:04 -0800), stermic@gw.co.jackson.mo.us (Michael Sterling) confessed: > i'm trying to get the max time stamp, from each day, of a range of > dates, not just the max time stamp for the complete range dates but > for each day. > Well, one gross and ugly way is: SELECT MAX( "when" ) FROM readings, (SELECT DATE_TRUNC( 'day', "when" ) AS period FROM readings GROUP BY period) AS p WHERE DATE_TRUNC( 'day', "when" ) = p.period GROUP BY p.period; given the table readings looks something like: CREATE TABLE readings ( "when" TIMESTAMP DEFAULT timeofday()::timestamp NOT NULL PRIMARY KEY ); I'm curious to see other, 'better' solutions. Cheers, Rob -- 12:52:57 up 20:36, 2 users, load average: 2.08, 2.17, 2.18 Linux 2.4.21-0.13_test #60 SMP Sun Dec 7 17:00:02 MST 2003 --Multipart_Sun__15_Feb_2004_13_00_25_-0700_=.9v9EXutjLmb9oy Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.2 (GNU/Linux) iEYEARECAAYFAkAvz98ACgkQLQ/DKuwDYzkKPACfXQSPtclOmvynZqNkJni8JaN8 rMkAniko3AXdzIAMNJK1Cq9P/Nk+90+5 =ODLo -----END PGP SIGNATURE----- --Multipart_Sun__15_Feb_2004_13_00_25_-0700_=.9v9EXutjLmb9oy--