Re: order by and aggregate

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: order by and aggregate
Дата
Msg-id 200301061341.32945.dev@archonet.com
обсуждение исходный текст
Ответ на order by and aggregate  (Tomasz Myrta <jasiek@klaster.net>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Bruno Wolff III
Дата:
Сообщение: Re: Grant execute on functions; related objects permissions ?
Следующее
От: Tomasz Myrta
Дата:
Сообщение: Re: order by and aggregate