Re: Do I just not understand count()? - Mailing list pgsql-general

From Tom Lane
Subject Re: Do I just not understand count()?
Date
Msg-id 22875.1018294241@sss.pgh.pa.us
Whole thread Raw
In response to Re: Do I just not understand count()?  ("Gregory Wood" <gregw@com-stock.com>)
List pgsql-general
"Gregory Wood" <gregw@com-stock.com> writes:
> I'm not sure exactly what it does with "a=1" though... I'm
> guessing that it returns a boolean value, which means that it counts as a
> row (only NULL values are not counted in count()).

Yup, Greg gets a gold star: COUNT *only* cares whether its input is NULL
or not, not what specific value it might have.  This is per SQL spec.

The nearby suggestions involving SUM() look like they would work to
accumulate counts of different conditions in a single pass.

            regards, tom lane

pgsql-general by date:

Previous
From: Michael Adler
Date:
Subject: Re: inherited columns as foreign keys WAS "no subject"
Next
From: Tom Lane
Date:
Subject: Re: vacuuming not working?