pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Michael Fuhr <mike@fuhr.org>
To: Jeffrey Melloy <jmelloy@visualdistortion.org>
Cc: Weimao Ke <wke@indiana.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: pgsql aggregate: conditional max
Date: Sat, 11 Mar 2006 22:48:54 -0700
Message-ID: <20060312054854.GA25553@winnie.fuhr.org> (raw)
In-Reply-To: <4413B301.7070207@visualdistortion.org>
References: <4413AD1C.9050604@indiana.edu>
	<4413B301.7070207@visualdistortion.org>

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



view thread (9+ messages)  latest in thread

Message-ID: <20060312054854.GA25553@winnie.fuhr.org>
Permalink:  ../20060312054854.GA25553@winnie.fuhr.org/
Also on:    postgresql.org/message-id/20060312054854.GA25553@winnie.fuhr.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mike@fuhr.org, jmelloy@visualdistortion.org, wke@indiana.edu
  Subject: Re: pgsql aggregate: conditional max
  In-Reply-To: <20060312054854.GA25553@winnie.fuhr.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox