Solved

How to include NULL values in Group Count

Posted on 2010-11-16
3
676 Views
Last Modified: 2012-05-10
Experts,

How can I create a Query that groups on a field and counts NULL values as well.

Tier 2     62
Tier 3     15

That's all. However there are 134 records. I would like the query to list:
Tier 2     62
Tier 3     15
Blank      57

I tried linking to a query with:

SELECT Count(*) AS NoTier
FROM tblStudent
WHERE (((tblStudent.tblStdTier) Is Null));

But because I am grouping my results are

Tier 2     62     57
Tier 3     15     57

I really need:
Tier 2     62
Tier 3     15
Blank      57

Because I am displaying the results in a continous form on a statistics page.

Thanks!



SELECT tblStudent.tblStdTier AS Tier, Count(tblStudent.tblStdTier) AS [Count]

FROM tblStudent

GROUP BY tblStudent.tblStdTier

HAVING (((tblStudent.tblStdTier)<>"0"));

Open in new window

0
Comment
Question by:shogun5
  • 2
3 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 34144896

try this


SELECT iif([tblStdTier] is null, "NoTier",[tblstdtier]) AS Tier, Count(ID) AS [Count]
FROM tblStudent
GROUP BY iif([tblStdTier] is null, "NoTier",[tblstdtier])
HAVING (((iif([tblStdTier] is null, "NoTier",[tblstdtier]))<>"0"));
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 500 total points
ID: 34144901
or this

SELECT iif([tblStdTier] is null, "NoTier",[tblstdtier]) AS Tier, Count(*) AS [Count]
FROM tblStudent
GROUP BY iif([tblStdTier] is null, "NoTier",[tblstdtier])
HAVING (((iif([tblStdTier] is null, "NoTier",[tblstdtier]))<>"0"));
0
 

Author Closing Comment

by:shogun5
ID: 34144962
Yep! That worked! Thank you!
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Close Print Preview button not active 12 36
Sub Reports 8 23
Error: Operation must use an updateable query 2 11
Field Size - Double?  Want to display 0 5 30
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now