Re: Aggregate Function to return most common value for a column

Поиск
Список
Период
Сортировка
От artacus@comcast.net
Тема Re: Aggregate Function to return most common value for a column
Дата
Msg-id 1792626127.9256531243005787312.JavaMail.root@sz0018a.emeryville.ca.mail.comcast.net
обсуждение исходный текст
Ответ на Aggregate Function to return most common value for a column  ("Michael Harris" <michael.harris@ericsson.com>)
Ответы Re: Aggregate Function to return most common value for a column  (David Fetter <david@fetter.org>)
Re: Aggregate Function to return most common value for a column  ("Michael Harris" <michael.harris@ericsson.com>)
Список pgsql-general
> I want to use an aggregate function that will return the most commonly
> occurring value in a column.

It's actually dead simple in Postgres. No C either. You just need to create an aggregate function.
I wrote a most() aggregate a while back that does exactly what you are asking for. Here, I'll add it to my blog...

http://scottrbailey.wordpress.com/2009/05/22/postgres-adding-custom-aggregates-most/


Scott Bailey

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

Предыдущее
От: Keith Hayden
Дата:
Сообщение: How to update stavaluesN columns in pg_statistics (type anyarry)
Следующее
От: Vick Khera
Дата:
Сообщение: Re: Tuning resource parameters for a logging database.