On Fri, Apr 19, 2002 at 04:40:35AM -0500, Tod McQuillin wrote:
> On Fri, 19 Apr 2002, Albrecht Berger wrote:
>
> > 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 ) !
>
> SELECT a, count(a) FROM resulttable GROUP BY a ORDER BY 2 DESC
Note that count on NULL values will always give you 0:
fduch=> INSERT INTO resulttable VALUES (NULL);
INSERT 1702218 1
(repeat some times)
fduch=> SELECT a, count(a) FROM resulttable GROUP BY a ORDER BY 2 DESC;a | count
----+-------12 | 314 | 210 | 115 | 1 | 0
(5 rows)
--
Fduch M. Pravking