Results 1 to 3 of 3
  1. #1
    BLD21 is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Apr 2011
    Posts
    55

    Multiple count of query fields

    access2007,



    I have a query that contains one table(tbl_rejects). In my query I have the fields of Company,Customer,Code,Code.

    Company and Customer are group by
    Code is count and the other Code is a where clause of "Reject"

    This will count the reject records for each company which is used in a report.

    What I would like to do is add the field "Flag" and to be able to count the "automated" records also.

    This is how my query pane looks:

    Company Customer Code Code Flag Flag
    tbl_rejects tbl_rejects tbl_rejects tbl_rejects tbl_rejects tbl_rejects
    Group By Group By Count Where Count Where
    "REJECTS" "AUTO"


    I need to see both the reject count and auto counts in my report.
    Should I try and use a separate query for the auto's, and if so how would I use that in my report. I am already using the reject query for the control source.
    Any ideas?

    Thanks,

    Bruce

  2. #2
    BLD21 is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Apr 2011
    Posts
    55
    The correct spacing is not saving correctly. Here is the sql:

    SELECT DISTINCTROW tbl_Rejects.COMPANY_NAME, tbl_Rejects.CUSTOMER_PROFILE_Description, Count(tbl_Rejects.SORT_DECISION_CODE) AS CountOfSORT_DECISION_CODE, Count(tbl_Rejects.AUTOMATION_FLAG) AS CountOfAUTOMATION_FLAG
    FROM tbl_Rejects
    WHERE (((tbl_Rejects.SORT_DECISION_CODE)="REJECT") AND ((tbl_Rejects.AUTOMATION_FLAG)="AUTOMATED"))
    GROUP BY tbl_Rejects.COMPANY_NAME, tbl_Rejects.CUSTOMER_PROFILE_Description;

  3. #3
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Is this sql working? Is the output wrong?
    I would approach it as follows:
    Get the query working to give the output you want, then use report wizard on the query.

    After posting I set up a small test.

    See attached jpg

    I changed the AND to OR so you would get the counts I think you want.

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

Similar Threads

  1. Form Based Query for Multiple Fields
    By sureelsaraf in forum Access
    Replies: 0
    Last Post: 03-28-2011, 06:14 PM
  2. SUM Multiple fields in a query
    By Thoudus in forum Queries
    Replies: 3
    Last Post: 02-24-2011, 09:11 AM
  3. Multiple Count Ifs and Expressions in Query
    By jonrockwell08 in forum Queries
    Replies: 1
    Last Post: 07-21-2010, 10:44 AM
  4. Replies: 1
    Last Post: 06-28-2010, 11:04 PM
  5. Multiple count query
    By aajay05 in forum Queries
    Replies: 2
    Last Post: 03-08-2010, 10:00 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