Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id E30D99F9784 for ; Tue, 28 Aug 2007 06:14:30 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 78015-08 for ; Tue, 28 Aug 2007 06:14:21 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from depesz.com (depesz.com [88.198.37.40]) by postgresql.org (Postfix) with ESMTP id 0EC989F9774 for ; Tue, 28 Aug 2007 06:14:24 -0300 (ADT) Received: from depesz by depesz.com with local (Exim 4.63) (envelope-from ) id 1IPx9R-0005TP-KL; Tue, 28 Aug 2007 11:14:21 +0200 Date: Tue, 28 Aug 2007 11:14:21 +0200 From: hubert depesz lubaczewski To: Claudia Kosny Cc: pgsql-sql@postgresql.org Subject: Re: fetch first rows of grouped data Message-ID: <20070828091421.GB19637@depesz.com> Reply-To: depesz@depesz.com References: <46D2FD9F.3020000@gmx.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <46D2FD9F.3020000@gmx.net> User-Agent: Mutt/1.5.13 (2006-08-11) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200708/233 X-Sequence-Number: 29171 On Mon, Aug 27, 2007 at 06:36:47PM +0200, Claudia Kosny wrote: > Is there a way to do this with one query? > I am using PostgreSQL 7.4. you can try to use "distinct on". depesz -- quicksil1er: "postgres is excellent, but like any DB it requires a highly paid DBA. here's my CV!" :) http://www.depesz.com/ - blog dla ciebie (i moje CV)