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 898FAD1DC01 for ; Sun, 15 Feb 2004 19:50:02 +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 68193-05 for ; Sun, 15 Feb 2004 15:49:57 -0400 (AST) Received: from wolff.to (wolff.to [66.93.249.74]) by svr1.postgresql.org (Postfix) with SMTP id 37D35D1DD1F for ; Sun, 15 Feb 2004 15:49:55 -0400 (AST) Received: (qmail 19670 invoked by uid 500); 15 Feb 2004 19:51:52 -0000 Date: Sun, 15 Feb 2004 13:51:52 -0600 From: Bruno Wolff III To: Michael Sterling Cc: pgsql-sql@postgresql.org Subject: Re: max timestamp Message-ID: <20040215195152.GA570@wolff.to> Mail-Followup-To: Michael Sterling , pgsql-sql@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.6i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/185 X-Sequence-Number: 16875 On Tue, Feb 10, 2004 at 10:14:04 -0800, Michael Sterling wrote: > 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. SELECT DISTINCT ON can probably do what you want. Something like: SELECT DISTINCT ON (timestamp::DATE) * FROM table ORDER BY timestamp DESC; This won't produce any records for days where there are no timestamps.