Re: Suggestion for aggregate function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Greg Stark <gsstark(at)mit(dot)edu>
Cc: Manfred Koizar <mkoi-pg(at)aon(dot)at>, Bruno Wolff III <bruno(at)wolff(dot)to>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Suggestion for aggregate function
Date: 2003-01-24 20:55:53
Message-ID: 22608.1043441753@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Greg Stark <gsstark(at)mit(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2003-01-24 21:09:48 Re: Client interfaces documentation
Previous Message Hannu Krosing 2003-01-24 20:35:39 Re: Postgresql source