display a count in a query when null

G

Guest

Hi, I would like to know how I can include null values in my count query. I
have 8 different categories and each have characteristics which I would like
a total of, but when I run the count query and the category has no
characteristics, it does not appear in the query at all. I would like to see
this category included with all others with a zero next to it. Thanks.
 
G

Guest

Thank you for your reply. I regret to say that I don't understand what I do
with that text. I entered it into SQL but no luck. Could you possibly expand
a little? Thanks.

Lynn Trapp said:
Select Count(NZ([FieldWithNulls],"N/A"))
From YourTable
Group By SomeField;

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Ben said:
Hi, I would like to know how I can include null values in my count query.
I
have 8 different categories and each have characteristics which I would
like
a total of, but when I run the count query and the category has no
characteristics, it does not appear in the query at all. I would like to
see
this category included with all others with a zero next to it. Thanks.
 
L

Lynn Trapp

Could you post your table structure and the SQL that you tried before I sent
that?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Ben said:
Thank you for your reply. I regret to say that I don't understand what I
do
with that text. I entered it into SQL but no luck. Could you possibly
expand
a little? Thanks.

Lynn Trapp said:
Select Count(NZ([FieldWithNulls],"N/A"))
From YourTable
Group By SomeField;

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm
Jeff Conrad's Access Junkie List:
http://home.bendbroadband.com/conradsystems/accessjunkie.html



Ben said:
Hi, I would like to know how I can include null values in my count
query.
I
have 8 different categories and each have characteristics which I would
like
a total of, but when I run the count query and the category has no
characteristics, it does not appear in the query at all. I would like
to
see
this category included with all others with a zero next to it. Thanks.
 
G

Guest

If I understand you correctly you'll need to join the Categories table to the
table which references it, i.e. the one which records the characteristics, in
a LEFT OUTER JOIN so that all categories are returned, e.g.

SELECT Categories.Category, COUNT(MyID) AS CountPerCategory
FROM Categories LEFT JOIN MyTable ON Categories.Category = MyTable.Category
GROUP BY Categories.Category;

where MyTable is the referencing table and MyID is its primary key.
 

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