Re: Do I just not understand count()?
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Gregory Wood" <gregw@com-stock.com>
Cc: "Ben" <bench@silentmedia.com>, "PostgreSQL-General" <pgsql-general@postgresql.org>
Date: 2002-04-08T19:30:41Z
Lists: 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