Counting SSNs if Null make 0

G

Guest

I have a query that counts mangers ssn, then another query that sums the
counts, and I use the sums query on a report to give me a total tally. In
the report I use a text box to sum the sums of the various types of managers,
to give me a categorized total.

Problem: one category of managers currently is unfilled and so there is no
count, no sum, and in the report the categorized Total fields are blank, I'm
assuming because it won't count the blank field, throwing everything off.

Can anyone assist? Thank you :)
 
M

MGFoster

franklinbukoski said:
I have a query that counts mangers ssn, then another query that sums the
counts, and I use the sums query on a report to give me a total tally. In
the report I use a text box to sum the sums of the various types of managers,
to give me a categorized total.

Problem: one category of managers currently is unfilled and so there is no
count, no sum, and in the report the categorized Total fields are blank, I'm
assuming because it won't count the blank field, throwing everything off.

Can anyone assist? Thank you :)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

To count rows w/ NULL columns use Count(*). Using Count(column_name)
only counts those rows that have a non-NULL value in the indicated
column.

The following info is from http://tinyurl.com/89azy You may not be able
to view this page w/o an account on that system. The main thrust is:

The COUNT() set function has two forms:

* COUNT(column) – Returns the count of rows in a table, less NULLs
* COUNT(*) – Returns the cardinality (total number of rows) of a
table

The following code demonstrates the difference between COUNT(column) and
COUNT(*):

SELECT COUNT(*) AS TotalRows, COUNT(region) AS NonNULLRows, COUNT(*) -
COUNT(region) AS NULLRows
FROM [suppliers]

This query returns the following result:

TotalRows NonNULLRows NULLRows
29 9 20
--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBRAorFYechKqOuFEgEQKZ6ACgq/p2Uwk84SPfy1V4DD+L1yInGF8AoNzU
b4GH0q7sGOtrRFojlUEBnL5V
=be0n
-----END PGP SIGNATURE-----
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top