Re: Suggestion for aggregate function

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Suggestion for aggregate function
Дата
Msg-id 22608.1043441753@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Suggestion for aggregate function  (Greg Stark <gsstark@mit.edu>)
Список pgsql-hackers
Greg Stark <gsstark@mit.edu> writes:
> What would be useful is something like

> SELECT item_id, 
>        first(price) as min_price, first(store_id) as min_store,
>        avg(price) as avg_price,
>        last(price) as max_price,  last(store_id) as min_store,
>        count(distinct store_id) as num_stores
>  FROM (SELECT * FROM items_for_sale ORDER BY item_id, store_id)
> GROUP BY store_id

Write it yourself --- both first() and last() are trivial to code as
user-defined aggregates.
        regards, tom lane


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

Предыдущее
От: Hannu Krosing
Дата:
Сообщение: Re: Postgresql source
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Client interfaces documentation