How to obtain a coalesce aggregation in a GROUP BY query?

From: Federico Dal Maso <f(dot)dalmaso(at)miriade(dot)it>
To: pgsql-sql(at)postgresql(dot)org
Subject: How to obtain a coalesce aggregation in a GROUP BY query?
Date: 2011-10-27 10:28:28
Message-ID: CAHf9ormkYtYwfv4V7=bzLL=Z-m0Unz4-_tDxbC806pEO5kp2Aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I need write a query like this

select coalesce_agg(col order by col asc) from some_table group by other_col

clearly the col column is nullable.
which is the best way (in terms of performance too) to obtain this?

Are there any built-in aggregate function or should I write a new aggregate
function with CREATE AGGREGATE?
Do you think coalesce_agg should be a built-in aggregation?

Thanks in advance

--
Federico Dal Maso

Browse pgsql-sql by date

  From Date Subject
Next Message Brent Dombrowski 2011-10-27 17:06:49 Re: how to use explain analyze
Previous Message Joel Stevenson 2011-10-26 17:22:34 Re: CTE or Subselect and outer joins not behaving as expected?