Re: order by and aggregate

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Tomasz Myrta <jasiek(at)klaster(dot)net>
Cc: Richard Huxton <dev(at)archonet(dot)com>, pgsql-sql(at)postgresql(dot)org
Subject: Re: order by and aggregate
Date: 2003-01-06 16:36:58
Message-ID: 14758.1041871018@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Tomasz Myrta <jasiek(at)klaster(dot)net> writes:
> Standard Postgresql aggregate functions don't need sorted data, but my
> function needs. Look at the data:
> <value> <sum>
> 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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tomasz Myrta 2003-01-06 16:59:54 Re: order by and aggregate
Previous Message Tomasz Myrta 2003-01-06 16:35:54 Re: order by and aggregate