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

2009-05-23 Thread Benjamin Smith
I've used this same concept in subqueries for a very long time. Doing this allows me to "dive in" and get other values from the joined table, rather than just the thing that we're getting the most of. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "I kept looking fo

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

2009-05-22 Thread Michael Harris
in my application that won't be a problem. Thanks again, Regards // Mike -Original Message- From: arta...@comcast.net [mailto:arta...@comcast.net] Sent: Saturday, 23 May 2009 1:23 AM To: Michael Harris Cc: pgsql-general@postgresql.org Subject: Re: [GENERAL] Aggregate Function to return m

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

2009-05-22 Thread Leif B. Kristensen
On Friday 22. May 2009, Alvaro Herrera wrote: >Hey, if you want to add your functions to > http://wiki.postgresql.org/wiki/Snippets , that would be great. +1 -- Leif Biberg Kristensen | Registered Linux User #338009 Me And My Database: http://solumslekt.org/blog/ -- Sent via pgsql-general maili

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

2009-05-22 Thread Alvaro Herrera
arta...@comcast.net wrote: > Excellent observation Dave. Sometimes I can't see outside of the box I'm in. > And at the time I was focusing on text so statistics was in another box. I've > update post with final functions for mode(), median() and range(). Hey, if you want to add your functions to

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

2009-05-22 Thread David Fetter
On Fri, May 22, 2009 at 05:23:47PM +, arta...@comcast.net wrote: > > On Fri, May 22, 2009 at 03:23:07PM +, arta...@comcast.net wrote: > > > I want to use an aggregate function that will return the most > > > commonly occurring value in a column. > > > > It's actually dead simple in Pos

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

2009-05-22 Thread artacus
On Fri, May 22, 2009 at 03:23:07PM +, arta...@comcast.net wrote: > > 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 m

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

2009-05-22 Thread David Fetter
On Fri, May 22, 2009 at 03:23:07PM +, arta...@comcast.net wrote: > > 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

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

2009-05-22 Thread artacus
> 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'

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

2009-05-22 Thread Ivan Sergio Borgonovo
On Fri, 22 May 2009 17:48:44 +1000 "Michael Harris" wrote: > Hi Experts, > > I want to use an aggregate function that will return the most > commonly occurring value in a column. > > The column consists of VARCHAR(32) values. > > Is it possible to construct such an aggregate using PL/PgSql ?

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

2009-05-22 Thread Pavel Stehule
Hello I thing, so the function in C is the best solution. And I thing, so you can use PostgreSQL functionality inside. Pg support hash arrays and hashing function too. regards Pavel Stehule 2009/5/22 Michael Harris : > Hi Experts, > > I want to use an aggregate function that will return the most

[GENERAL] Aggregate Function to return most common value for a column

2009-05-22 Thread Michael Harris
Hi Experts, I want to use an aggregate function that will return the most commonly occurring value in a column. The column consists of VARCHAR(32) values. Is it possible to construct such an aggregate using PL/PgSql ? If I was trying to do something like this in Perl I would use a hash table t