Re: count different values in column

From: "Gautham S(dot) Rao" <gautam(dot)rao(at)tatainfotech(dot)com>
To: "Albrecht Berger" <berger1517(at)gmx(dot)ch>, "pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: count different values in column
Date: 2002-04-19 10:00:56
Message-ID: 00db01c1e789$1a5294c0$41057aa3@tatainfotech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi Berger,

Try,
select a from Resulttable group by a having count(a) = (select max(cnt)
from (select count(a) as cnt from Resulttable group by a) as tmp);

Regards,
Gautham.

----- Original Message -----
From: "Albrecht Berger" <berger1517(at)gmx(dot)ch>
To: "pgsql" <pgsql-sql(at)postgresql(dot)org>
Sent: Friday, April 19, 2002 3:00 PM
Subject: [SQL] count different values in column

> 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
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Rajesh Kumar Mallah 2002-04-19 11:10:40 how to get index scan at work?
Previous Message Fduch the Pravking 2002-04-19 09:55:02 Re: count different values in column