NZ function - can't count

I have created a query where Status = 2, count all names as MemberQty - that works just fine - I get an answer of Status 2 and Members 145.
But when I change it to Status = 3, count all names as AssociateQty, it doesn't work because there are no Associates.  The answer is null.
Working in query design, I have 2 columns -Status and AssociateQTY: NZ([NCODE],0).  I believe this should give me an answer of Status 3 and Associate 0 - but it doesn't.
Any help would be appreciated

msmerryAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Patrick MatthewsCommented:
Please post the full SQL statement you are using.
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
Can you post the SQL for the query?
mx
0
Rey Obrero (Capricorn1)Commented:
try a query like this


SELECT Table3.Status, Sum(IIf([Status]=2,1,0)) AS MemberQty, Sum(IIf([Status]=3,1,0)) AS AssociateQty
FROM Table3
GROUP BY Table3.Status;
0
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

msmerryAuthor Commented:
As requested, the SQL statement

SELECT [2BMembershiptbl].Status, [TBL STATUS].EXPLANATION, Count(NZ([NCODE],0)) AS MEMBERQTY
FROM (2AANAMES INNER JOIN 2BMembershiptbl ON [2AANAMES].ACODE = [2BMembershiptbl].MCODE) INNER JOIN [TBL STATUS] ON [2BMembershiptbl].Status = [TBL STATUS].STATUS
GROUP BY [2BMembershiptbl].Status, [TBL STATUS].EXPLANATION
HAVING ((([2BMembershiptbl].Status)="2"));
0
Rey Obrero (Capricorn1)Commented:

try this query

SELECT [2BMembershiptbl].Status, [TBL STATUS].EXPLANATION, Sum(IIf([Status]=2,1,0)) AS MemberQty, Sum(IIf([Status]=3,1,0)) AS AssociateQty
FROM (2AANAMES INNER JOIN 2BMembershiptbl ON [2AANAMES].ACODE = [2BMembershiptbl].MCODE) INNER JOIN [TBL STATUS] ON [2BMembershiptbl].Status = [TBL STATUS].STATUS
GROUP BY [2BMembershiptbl].Status, [TBL STATUS].EXPLANATION
0
msmerryAuthor Commented:
Capricorn1 thank you, that works perfectly - all I need to finish the job is how to make a Total
0
Rey Obrero (Capricorn1)Commented:
msmerry,
if your original question/problem was resolved by a post/s, please accept the comment to close this thread and open new one for your other requirements.

you will get faster respond if you will limit your question to one per thread.

after you close the thread, you can click the "ask a related question"  at the bottom of the page.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
msmerryAuthor Commented:
Thanks Capricorn1
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.