From: Richard Huxton <dev@archonet.com>
To: Tomasz Myrta <jasiek@klaster.net>
To: pgsql-sql@postgresql.org
Subject: Re: order by and aggregate
Date: Mon, 6 Jan 2003 13:41:32 +0000
Message-ID: <200301061341.32945.dev@archonet.com> (raw)
In-Reply-To: <3E197A39.8070808@klaster.net>
References: <3E197A39.8070808@klaster.net>
On Monday 06 Jan 2003 12:44 pm, Tomasz Myrta wrote:
> Hi
> I created my own aggregate function working as max(sum(value))
> It adds positive and negative values and finds maximum of this sum.
> To work properly this function needs data to be sorted.
I'm not sure that an aggregate function should require data to be sorted
before processing. Could you show details of your function - there may be a
way to rewrite it to handle unsorted data.
> select
> maxsum(value)
> from some_table
> order by some_field
>
> doesn't work:
> ERROR: Attribute some_table.some_field must be GROUPed or used in an
> aggregate function
The "order by" isn't necessarily handled before calculating maxsum() anyway.
--
Richard Huxton
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: dev@archonet.com, jasiek@klaster.net
Subject: Re: order by and aggregate
In-Reply-To: <200301061341.32945.dev@archonet.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