Re: count different values in column

From: Christoph Haller <ch(at)rodos(dot)fzk(dot)de>
To: berger1517(at)gmx(dot)ch (Albrecht Berger)
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: count different values in column
Date: 2002-04-19 11:46:48
Message-ID: 200204190946.LAA12543@rodos
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

select max(count) from (
select a, count(a) from Resulttable group by a
) as foo;
max
-----
3
(1 row)
should do it.
Regards, Christoph

> Hello,
> today I have a new question :)
>
> I've a resulttable is generated by a couple of subselects and joins which
> contains only one column.
>
> Now I want to count the different values in the column.
>
> Resulttable :
> a
> ------
> 10
> 12
> 12
> 12
> 14
> 14
> 15
>
> I need the value which is repeated most in the resulttable (in this example
> 12 ) !
>
>
> Any suggestions ?
>
>
> Thx
> berger
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Bjarte Aagnes 2002-04-19 13:00:09 Re: [SQL] MAX(column1),MAX(column2),...
Previous Message Thomas Swan 2002-04-19 11:23:27 Re: how to get index scan at work?