From: Michael Richards <michael@fastmail.ca>
To: tgl@sss.pgh.pa.us
Cc: pgsql-sql@postgresql.org
Subject: Re: finding a maximum or minimum sum
Date: Mon, 11 Jun 2001 15:03:29 -0400 (EDT)
Message-ID: <3B251601.000107.67770@frodo.searchcanada.ca> (raw)
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@postgresql.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@slickness.org)
Received: from localhost (dave@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@slickness.org>
X-X-Sender: <dave@bubbles.electricutopia.net>
To: =?iso-8859-1?q?Mart=EDn=20Marqu=E9s?= <martin@bugs.unl.edu.ar>
cc: pgsql sql Mailing List <pgsql-sql@postgresql.org>,
<pgsql-general@postgresql.org>
Subject: Re: ORDER BY what?
In-Reply-To: <01061111193103.29653@bugs>
Message-ID: <Pine.LNX.4.31.0106111622110.2923-100000@bubbles.electricutopia.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, Martín Marqués 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
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: michael@fastmail.ca, tgl@sss.pgh.pa.us
Subject: Re: finding a maximum or minimum sum
In-Reply-To: <3B251601.000107.67770@frodo.searchcanada.ca>
References: <3B251601.000107.67770@frodo.searchcanada.ca>
* 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