...

View Full Version : Quick COUNT() question



Jak-S
07-21-2006, 10:35 AM
The MySQL documentation says:


COUNT(DISTINCT expr,[expr...])

Returns a count of the number of different non-NULL values.

How do i get it to INCLUDE null values? I am using COUNT with the DISTINCT bit as well, and i want the NULL rows to count as one as well.

Thanks,
Jack

guelphdad
07-21-2006, 11:49 AM
what are you trying to count? Distinct tools for instance?

If you have
wrench, wrench, hammer, null, null, null, screwdriver


and you are trying to count the distinct things then you have 3 tools.
if you are trying to count the nulls in there as well each null is distinct from the other so you have six tools. Is that really what you want?

In order to count nulls you need count(*) but of course that would include two counts for wrench.

Jak-S
07-21-2006, 12:59 PM
Actually ive realised i was trying to do the wrong thing and it works differently now. Thanks anyway.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum