Re: order by and aggregate - Mailing list pgsql-sql

From Tom Lane
Subject Re: order by and aggregate
Date
Msg-id 14758.1041871018@sss.pgh.pa.us
Whole thread Raw
In response to Re: order by and aggregate  (Tomasz Myrta <jasiek@klaster.net>)
List pgsql-sql
Tomasz Myrta <jasiek@klaster.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


pgsql-sql by date:

Previous
From: Tom Lane
Date:
Subject: Re: order by and aggregate
Next
From: Tomasz Myrta
Date:
Subject: Re: order by and aggregate