Results 1 to 4 of 4
  1. #1
    Dulanic is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    4

    Count Query w/o ignoring Nulls

    Is there any way to do this? Right now I have something like so....



    Code:
    SELECT mgr_name, Count(*) AS COHCnt
    FROM tblAudits
    WHERE xyz....
    GROUP BY  mgr_name
    The problem is, it ignores 0's if there was no results from the where conditions... I need it to basically provide a list of the mgr_name and then if there was 0 results for said manager it provides a 0. I had ready that before I could do a Group by all, but I guess that is older and no longer works? Not sure, it gave an error message.

    Right now it would show for example...

    Mgr1 5
    Mgr2 3
    Mgr4 2

    I need it to show....

    Mgr1 5
    Mgr2 3
    Mgr3 0
    Mgr4 2
    Last edited by Dulanic; 03-21-2012 at 11:48 AM.

  2. #2
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You will need a new query that brings in all manager names and left join that to your counting query. You will also need an IIF(IsNull()) nested function to force zero when no applicable count exists for a manager. The query would look something like this (you will have to substitute your actual field/table/query names):

    SELECT tblManagers.mgr_name, IIF( IsNull(CountingQuery.COHCnt), 0 CountingQuery.COHCnt) as AuditCount
    FROM tblMangers LEFT JOIN CountingQuery ON tblManagers.mgr_name=CountingQuery.mgr_name

  3. #3
    Dulanic is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Mar 2012
    Posts
    4
    Thanks much! I made a few tweaks and was able to get that to work. Appreciate the help.

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    You're welcome. Glad you were able to get to a solution!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. VBA excluding (Ignoring) Comma
    By RedWolf3x in forum Programming
    Replies: 3
    Last Post: 11-11-2011, 05:15 PM
  2. handling nulls in mulitple parameter query
    By haggisns in forum Queries
    Replies: 5
    Last Post: 10-14-2010, 02:09 PM
  3. SUM in regards to nulls
    By detlion1643 in forum Access
    Replies: 5
    Last Post: 02-03-2010, 08:50 AM
  4. Replies: 2
    Last Post: 01-18-2010, 11:52 AM
  5. Replies: 1
    Last Post: 07-14-2008, 12:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums