X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 1BFF03A5D38 for ; Wed, 12 Jan 2005 17:41:51 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 50447-07 for ; Wed, 12 Jan 2005 17:41:40 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id 3B78B3A5D17 for ; Wed, 12 Jan 2005 17:41:37 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j0CHfVmr051733 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 12 Jan 2005 10:41:33 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j0CHfUfa095339; Wed, 12 Jan 2005 10:41:30 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j0CHfUb1095338; Wed, 12 Jan 2005 10:41:30 -0700 (MST) (envelope-from mfuhr) Date: Wed, 12 Jan 2005 10:41:30 -0700 From: Michael Fuhr To: Kaloyan Iliev Iliev Cc: pgsql-sql@postgresql.org Subject: Re: Problems with HAVING Message-ID: <20050112174130.GA95306@winnie.fuhr.org> References: <41E5529B.9030609@faith.digsys.bg> <20050112171121.GA94838@winnie.fuhr.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050112171121.GA94838@winnie.fuhr.org> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.002 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/63 X-Sequence-Number: 19851 On Wed, Jan 12, 2005 at 10:11:21AM -0700, Michael Fuhr wrote: > On Wed, Jan 12, 2005 at 06:38:51PM +0200, Kaloyan Iliev Iliev wrote: > > > My problem is that I want to select the row with max(date) but also > > limited with where clauses. > > If you don't mind using a non-standard feature then try SELECT > DISTINCT ON (not just DISTINCT, but DISTINCT ON): Sorry, I probably didn't read your message closely enough. If you just want a single record then ORDER BY ... LIMIT 1 might be more appropriate. -- Michael Fuhr http://www.fuhr.org/~mfuhr/