"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