From: Tomasz Myrta <jasiek@klaster.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Richard Huxton <dev@archonet.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: order by and aggregate
Date: Mon, 06 Jan 2003 17:59:54 +0100
Message-ID: <3E19B60A.9080701@klaster.net> (raw)
In-Reply-To: <3E197A39.8070808@klaster.net>
References: <3E197A39.8070808@klaster.net>
<200301061341.32945.dev@archonet.com>
<3E198E18.5090408@klaster.net>
<14758.1041871018@sss.pgh.pa.us>
Tom Lane wrote:
> Tomasz Myrta writes:
>
> >Standard Postgresql aggregate functions don't need sorted data, but my
> >function needs. Look at the data:
> >
> >3 3
> >-2 1
> >6 7 *** max_sum=7
> >-3 4
> >2 6
>
>
> But if the input data is sorted into increasing order, then the largest
> running sum value is always at the end. Therefore max(sum()) is
> equivalent to sum(); therefore you do not need the special aggregate,
> nor the ordering.
>
> regards, tom lane
Sorting data by "value" was only an example,
In my case data is sorted by another key and has mixed positive and
negative values.
Tomasz Myrta
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: jasiek@klaster.net, tgl@sss.pgh.pa.us, dev@archonet.com
Subject: Re: order by and aggregate
In-Reply-To: <3E19B60A.9080701@klaster.net>
* 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