Re: pgsql aggregate: conditional max - Mailing list pgsql-sql

From Michael Fuhr
Subject Re: pgsql aggregate: conditional max
Date
Msg-id 20060312054854.GA25553@winnie.fuhr.org
Whole thread Raw
In response to Re: pgsql aggregate: conditional max  (Jeffrey Melloy <jmelloy@visualdistortion.org>)
Responses Re: pgsql aggregate: conditional max
List pgsql-sql
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 Fuhr


pgsql-sql by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: pgsql aggregate: conditional max
Next
From: Daniel CAUNE
Date:
Subject: Re: pgsql aggregate: conditional max