Results 1 to 4 of 4
  1. #1
    cardgage is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    50

    Show zero value in count query

    Good afternoon all,



    I am currently working with a database that stores (among other things) the number of interventions for each admission. When running a simply query to count the number of interventions per admission, everything works except that it omits admissions where no interventions took place. I would like the query to return zero values as well, but cannot seem to get the database to do so. Here is the SQL statement from the simple query that I created in the wizard:

    SELECT tblAdmissions.AdmissionID, Count(tblInterventions.IntType) AS CountOfIntType
    FROM tblAdmissions INNER JOIN tblInterventions ON tblAdmissions.AdmissionID = tblInterventions.AdmissionID
    GROUP BY tblAdmissions.AdmissionID;

    I tried replacing "Count(tblInterventions.IntType)" with "Nz(Count(tblInterventions.IntType),0)" to no avail. Any help with this will be greatly appreciated!

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try changing your join from an INNER JOIN to a LEFT JOIN.

  3. #3
    cardgage is offline Advanced Beginner
    Windows 7 32bit Access 2007
    Join Date
    Jan 2011
    Posts
    50
    Thank you JoeM - worked like a charm!

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome!

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

Similar Threads

  1. Replies: 1
    Last Post: 03-06-2017, 06:48 AM
  2. show a 0 if there is nothing to count in a query
    By megatronixs in forum Queries
    Replies: 10
    Last Post: 08-21-2015, 05:31 AM
  3. Replies: 3
    Last Post: 01-04-2015, 03:00 PM
  4. Show Count from different Zip Codes
    By jo15765 in forum Queries
    Replies: 6
    Last Post: 04-15-2013, 12:36 PM
  5. Replies: 1
    Last Post: 01-24-2011, 03:03 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