From: Alex Pilosov <alex@pilosoft.com>
To: Michael Richards <michael@fastmail.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: finding a maximum or minimum sum
Date: Mon, 11 Jun 2001 13:49:40 -0400 (EDT)
Message-ID: <Pine.BSO.4.10.10106111348530.16686-100000@spider.pilosoft.com> (raw)
In-Reply-To: <3B24F48D.000035.19989@frodo.searchcanada.ca>
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?
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: alex@pilosoft.com, michael@fastmail.ca
Subject: Re: finding a maximum or minimum sum
In-Reply-To: <Pine.BSO.4.10.10106111348530.16686-100000@spider.pilosoft.com>
References: <3B24F48D.000035.19989@frodo.searchcanada.ca> <Pine.BSO.4.10.10106111348530.16686-100000@spider.pilosoft.com>
* 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