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 0190E528A8 for ; Sat, 25 Jun 2005 02:32:51 -0300 (ADT) 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 28028-01 for ; Sat, 25 Jun 2005 05:32:49 +0000 (GMT) Received: from window.monsterlabs.com (window.monsterlabs.com [216.183.105.176]) by svr1.postgresql.org (Postfix) with SMTP id 2963752822 for ; Sat, 25 Jun 2005 02:32:47 -0300 (ADT) Received: (qmail 7973 invoked from network); 25 Jun 2005 05:32:47 -0000 Received: from host-209.149.56.238.nashville.net (HELO ?10.0.1.3?) (209.149.56.238) by 0 with SMTP; 25 Jun 2005 05:32:47 -0000 In-Reply-To: <7fdee0e68098da02600bf51be5a7f3f5@biglumber.com> References: <7fdee0e68098da02600bf51be5a7f3f5@biglumber.com> Mime-Version: 1.0 (Apple Message framework v730) Content-Type: text/plain; charset=WINDOWS-1252; delsp=yes; format=flowed Message-Id: <62592AAD-20CB-42EC-B599-E1D42D16A7BC@sitening.com> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: quoted-printable From: "Thomas F. O'Connell" Subject: Re: Grouping Too Closely Date: Sat, 25 Jun 2005 00:32:45 -0500 To: "Greg Sabino Mullane" X-Mailer: Apple Mail (2.730) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200506/298 X-Sequence-Number: 21899 This doesn't give me quite what I'm looking for because I need there =20 to be only one of each possible value of seq2 to be returned for each =20= value of fkey. -- Thomas F. O'Connell Co-Founder, Information Architect Sitening, LLC Strategic Open Source: Open Your i=99 http://www.sitening.com/ 110 30th Avenue North, Suite 6 Nashville, TN 37203-6320 615-260-0005 On Jun 24, 2005, at 11:22 PM, Greg Sabino Mullane wrote: >> What I'd like to be able to do is select all records corresponding to >> the minimum value of seq1 for each value of seq2 corresponding to a >> given fkey (with a lower bound on the value of seq2). > > I'm not sure how uid figures in, but would this do what you want?: > > SELECT fkey, uid, seq2, min(seq1) > FROM my_table > WHERE seq2 > 2 > GROUP BY fkey, uid, seq2 > ORDER BY 1,2,3;