Results 1 to 3 of 3
  1. #1
    pbDudley is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Location
    New Orleans
    Posts
    48

    Query Count Records Unless another fie

    Hello
    I have a Count function query as below which combines 2 fields and creates what is called ASSIGNED_PLAN. This is my unique value
    Then it counts the records in a field called plan_site_name and calls it SitesAffected

    The outcome is this:
    ASSIGNED_PLAN SitesAffected


    N-9999 6
    N-7777 5

    Now I need to not count the records based off of if another field has a date value or not. If it has a date in the field called (Sites_CANCEL_DT, don't count the records in plan_site_name

    I don't know how to add that to my query below. Or if its possible in the MS Access 2010 query

    Any help is much appreciative.

    SELECT [tbl_plan_reviews].[plan_ctrl_cd] & "-" & [tbl_plan_reviews].[plan_ctrl_num] AS ASSIGNED_PLAN,
    Count(tbl_plan_sites.plan_site_name) AS SitesAffected
    FROM tbl_plan_reviews INNER JOIN tbl_plan_sites ON ( tbl_plan_reviews.plan_ctrl_num = tbl_plan_sites.plan_ctrl_num ) AND ( tbl_plan_reviews.plan_ctrl_cd = tbl_plan_sites.plan_ctrl_cd )
    GROUP BY [tbl_plan_reviews].[plan_ctrl_cd] & "-" & [tbl_plan_reviews].[plan_ctrl_num]
    ORDER BY [tbl_plan_reviews].[plan_ctrl_cd] & "-" & [tbl_plan_reviews].[plan_ctrl_num];

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    If you are doing this is query design (which I recommend) add the date field and use "WHERE" in the total line, then add your criteria below.

  3. #3
    pbDudley is offline Advanced Beginner
    Windows 10 Access 2010 64bit
    Join Date
    Mar 2017
    Location
    New Orleans
    Posts
    48
    thank you, i overlooked that this morning, Im using query design, the sql above was copied out of the SQL viewer

    thanks

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

Similar Threads

  1. Replies: 5
    Last Post: 02-08-2017, 05:52 PM
  2. Replies: 4
    Last Post: 03-29-2014, 01:29 AM
  3. Replies: 1
    Last Post: 01-24-2013, 05:50 PM
  4. COUNT Group Count Records COUNT FUNCTION
    By PMCOFFEY in forum Access
    Replies: 9
    Last Post: 11-09-2012, 09:40 PM
  5. Query to count records
    By jpkeller55 in forum Access
    Replies: 4
    Last Post: 10-24-2010, 09:24 AM

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