Re: finding a maximum or minimum sum

From: Alex Pilosov <alex(at)pilosoft(dot)com>
To: Michael Richards <michael(at)fastmail(dot)ca>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: finding a maximum or minimum sum
Date: 2001-06-11 17:49:40
Message-ID: Pine.BSO.4.10.10106111348530.16686-100000@spider.pilosoft.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, 11 Jun 2001, Michael Richards wrote:

> I run a select sum(amount) from payments group by userid
> userid | sum
> --------------
> 1 | $500
> 2 | $310
> 3 | $20
>

> I need to modify this query so it returns the minimum, maximum and
> average sums. Is there any way I can do this?
select sum(amount),min(amount),max(amount) from payments group by userid

Is that what you mean? Or you want min/max _not_ to be grouped by userid?

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Richards 2001-06-11 18:22:01 Re: finding a maximum or minimum sum
Previous Message Josh Berkus 2001-06-11 17:44:01 Re: Table design issue....