Results 1 to 3 of 3
  1. #1
    Vaporhead is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2024
    Posts
    13

    Date Count Function

    Hello.

    I am trying to create a query that counts the amount of injuries each one of my store locations have had for a certain date period. If a location has not had an injury, then I want it to return a zero value. If I add my date field [DOI] from [tblmishaps] with any sort of criteria entered, it seems to return only results that have this criteria and ignores my RIGHT JOIN.

    Tables:
    "Locations"
    "tblMishaps"

    SELECT Locations.[Location Name], Count(tblMishaps.ID) AS [Total Mishaps]
    FROM tblMishaps RIGHT JOIN Locations ON tblMishaps.[Store Location] = Locations.[Location Name]
    WHERE (((tblMishaps.DOI) Between #4/1/2023# And #4/1/2024#))
    GROUP BY Locations.[Location Name];

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    It's not ignored, just joined at wrong point. Build aggregate query with filter then join the aggregate query to Locations.



    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Vaporhead is offline Novice
    Windows 10 Office 365
    Join Date
    Feb 2024
    Posts
    13
    Not sure why I didn't think of that. Thanks.

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

Similar Threads

  1. Replies: 10
    Last Post: 08-01-2023, 11:56 AM
  2. Replies: 17
    Last Post: 09-12-2020, 01:28 AM
  3. Count Function Help
    By cbramsey in forum Queries
    Replies: 11
    Last Post: 03-23-2017, 09:21 AM
  4. Count(*) function
    By FJM in forum Access
    Replies: 18
    Last Post: 09-13-2013, 07:47 PM
  5. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 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