Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to include NULL values in Group Count

Posted on 2010-11-16
3
Medium Priority
?
716 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Instead of error trapping or hard-coding for non-updateable fields when using QODBC, let VBA automatically disable them when forms open. This way, users can view but not change the data. Part 1 explained how to use schema tables to do this. Part 2 h…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

610 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