X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id C09D49DC8E0 for ; Sun, 12 Mar 2006 13:02:39 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45584-02 for ; Sun, 12 Mar 2006 13:02:38 -0400 (AST) X-Greylist: delayed 11:52:46.193172 by SQLgrey- Received: from rockridge.uits.indiana.edu (rockridge.uits.indiana.edu [129.79.1.74]) by postgresql.org (Postfix) with ESMTP id 875B79DC87E for ; Sun, 12 Mar 2006 13:02:37 -0400 (AST) Received: from mail-relay.iu.edu (stjoseph.uits.indiana.edu [129.79.1.78]) by rockridge.uits.indiana.edu (8.12.10/8.12.10/IUPO) with ESMTP id k2CGt4EU010099; Sun, 12 Mar 2006 11:55:05 -0500 (EST) Received: from [192.168.0.3] (149-159-1-54.dhcp-bl.indiana.edu [149.159.1.54]) (authenticated bits=0) by mail-relay.iu.edu (8.12.10/8.12.10/IUPO) with ESMTP id k2CGt27r024815; Sun, 12 Mar 2006 11:55:04 -0500 (EST) Message-ID: <44145265.6030100@indiana.edu> Date: Sun, 12 Mar 2006 11:55:01 -0500 From: Weimao Ke User-Agent: Mozilla Thunderbird 1.0.2 (Windows/20050317) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Michael Fuhr CC: Jeffrey Melloy , pgsql-sql@postgresql.org Subject: Re: pgsql aggregate: conditional max References: <4413AD1C.9050604@indiana.edu> <4413B301.7070207@visualdistortion.org> <20060312054854.GA25553@winnie.fuhr.org> In-Reply-To: <20060312054854.GA25553@winnie.fuhr.org> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0.479 required=5 tests=[DNS_FROM_RFC_ABUSE=0.479] X-Spam-Score: 0.479 X-Spam-Level: X-Archive-Number: 200603/173 X-Sequence-Number: 24519 Michael Fuhr wrote: >On Sun, Mar 12, 2006 at 12:34:57AM -0500, Jeffrey Melloy wrote: > > >>Should be able to do this with a standard max() aggregate. >> >>select aid, cat, max(weight) >>from table >>group by aid, cat; >> >> > >That query returns the maximum weight for each (aid, cat) pair. >Against the example data it returns the entire table, not the >(aid, cat) pair with the max weight for a given aid. > > > Michael is right. This query does not solve the problem... -- All best, Weimao Weimao Ke Indiana University Bloomington School of Library and Information Science http://ella.slis.indiana.edu/~wke