pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gautham S. Rao <gautam.rao@tatainfotech.com>
To: Albrecht Berger <berger1517@gmx.ch>
To: pgsql <pgsql-sql@postgresql.org>
Subject: Re: count different values in column
Date: Fri, 19 Apr 2002 15:30:56 +0530
Message-ID: <00db01c1e789$1a5294c0$41057aa3@tatainfotech.com> (raw)
References: <007901c1e784$e3c21010$a57ba8c0@wxp>

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@gmx.ch>
To: "pgsql" <pgsql-sql@postgresql.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
>




view thread (7+ messages)  latest in thread

Message-ID: <00db01c1e789$1a5294c0$41057aa3@tatainfotech.com>
Permalink:  ../00db01c1e789$1a5294c0$41057aa3@tatainfotech.com/
Also on:    postgresql.org/message-id/00db01c1e789$1a5294c0$41057aa3@tatainfotech.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: gautam.rao@tatainfotech.com, berger1517@gmx.ch
  Subject: Re: count different values in column
  In-Reply-To: <00db01c1e789$1a5294c0$41057aa3@tatainfotech.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox