Re: Suggestion for aggregate function - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Suggestion for aggregate function
Date
Msg-id 22608.1043441753@sss.pgh.pa.us
Whole thread Raw
In response to Re: Suggestion for aggregate function  (Greg Stark <gsstark@mit.edu>)
List 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 by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: Postgresql source
Next
From: Tom Lane
Date:
Subject: Re: Client interfaces documentation