Re: finding a maximum or minimum sum

From: "Michael Richards" <michael(at)fastmail(dot)ca>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: finding a maximum or minimum sum
Date: 2001-06-11 19:03:29
Message-ID: 3B251601.000107.67770@frodo.searchcanada.ca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Puuuurfect! This is exactly what I needed. Didn't know postgres
supported subselects like that. Thanks.

-Michael

> select min(amtsum), max(amtsum), avg(amtsum)
> from (select sum(amount) as amtsum from payments group by userid)
> ss;
>
> In prior versions you'd need to do the initial select into a temp
> table and then select min/max/avg from that.

_________________________________________________________________
http://fastmail.ca/ - Fast Free Web Email for Canadians
>From pgsql-sql-owner(at)postgresql(dot)org Mon Jun 11 19:24:18 2001
Received: from bubbles.electricutopia.net (bubbles.electricutopia.net [63.214.178.76])
by postgresql.org (8.11.3/8.11.1) with ESMTP id f5BNOFE37903;
Mon, 11 Jun 2001 19:24:15 -0400 (EDT)
(envelope-from dave(at)slickness(dot)org)
Received: from localhost (dave(at)localhost)
by bubbles.electricutopia.net (8.9.3/8.9.3) with ESMTP id QAA03026;
Mon, 11 Jun 2001 16:23:29 -0700
Date: Mon, 11 Jun 2001 16:23:29 -0700 (PDT)
From: David Olbersen <dave(at)slickness(dot)org>
X-X-Sender: <dave(at)bubbles(dot)electricutopia(dot)net>
To: =?iso-8859-1?q?Mart=EDn=20Marqu=E9s?= <martin(at)bugs(dot)unl(dot)edu(dot)ar>
cc: pgsql sql Mailing List <pgsql-sql(at)postgresql(dot)org>,
<pgsql-general(at)postgresql(dot)org>
Subject: Re: ORDER BY what?
In-Reply-To: <01061111193103(dot)29653(at)bugs>
Message-ID: <Pine(dot)LNX(dot)4(dot)31(dot)0106111622110(dot)2923-100000(at)bubbles(dot)electricutopia(dot)net>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=iso-8859-1
Content-Transfer-Encoding: 8bit
X-MIME-Autoconverted: from QUOTED-PRINTABLE to 8bit by postgresql.org id f5BNOGE37905
X-Archive-Number: 200106/170
X-Sequence-Number: 3393

On Mon, 11 Jun 2001, Martn Marqus wrote:

> My question is: "How can I write an ORDER BY statment so that it's ordered by
> the amount of matches it gets?"

Your question is a bit unclear, what is "it"?
Specifically, what are the "it's" that are to be ordered, and which "it" gets
matches?

-- Dave

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2001-06-11 19:09:41 Re: Table design issue....
Previous Message Tom Lane 2001-06-11 18:46:45 Re: finding a maximum or minimum sum