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

    Counts & Calcuations in Select Query

    2007, I have a simple select query using one table and the fields below:

    Company Name
    Description
    Decision Code

    I need to show by COMPANY the Total count of DECISION CODES and of those the Total count that were "REJECT".

    I would then like to take the Total Reject and / Total Number for a percentage.

    Company Description Total Count Reject Count Percentage
    Example: Acxiom 123acx 1,273 53 4.16%

    I havn't used Access since 03 and am trying to get back in the saddle.



    Thanks to all who reply!!

    Bruce D.
    Last edited by BLD21; 04-08-2011 at 09:05 AM. Reason: spacing incorrect

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    have you tried anything yet??

  3. #3
    BLD21 is offline Advanced Beginner
    Windows 2K Access 2007
    Join Date
    Apr 2011
    Posts
    55
    I am trying to query two counts on the same field unsuccessfully.

    I created a second identical field and named it Source Code2.
    In my query I have a count for Source Code Where Source Code = "REJECT" and a count for Source Code2 Where Source Code = "Like *" to try and get the total count of records in the field. But I can only manage one total or the other.

    Any ideas?

    Bruce

  4. #4
    jzwp11 is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2010
    Location
    Dayton, OH
    Posts
    2,901
    I would create two queries, one for the reject and the other for the total. Group both queries by the company (not sure whether the description field is necessary). Save both queries

    Create a third query that includes both of the above queries and join them by the company field. Select the company field and the two count fields and then add a calculated field for the percentage determination.

  5. #5
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    Quote Originally Posted by BLD21 View Post
    I need to show by COMPANY the Total count of DECISION CODES and of those the Total count that were "REJECT".
    this can be done such as:

    Code:
    select company, count(codes) as whatever
    
    from ....
    
    group by company
    
    where codes = ''reject''
    Quote Originally Posted by BLD21 View Post
    I would then like to take the Total Reject and / Total Number for a percentage.
    couldn't this be done in one query, without even needing the one above??

    for instance:

    [CODE]
    Code:
    select distinct company, 
    
    dsum("codes", "table", "[company] = '" & [company] & "'") as totalcount,
    
    dsum("codes", "table", "[company] = '" & [company] & "' AND 
    
    [codes] = 'reject'") as totalrejected,
    
    ([totalrejected] / [totalcount]) as percentage
    
    from table
    just an idea...

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

Similar Threads

  1. sql for grouping and counts
    By TheShabz in forum Queries
    Replies: 2
    Last Post: 11-04-2010, 02:01 PM
  2. Replies: 4
    Last Post: 10-01-2010, 12:06 PM
  3. Replies: 23
    Last Post: 06-30-2010, 02:05 PM
  4. Reporting counts in another query...maybe?
    By Geewaagh in forum Queries
    Replies: 7
    Last Post: 06-04-2010, 07:39 PM
  5. Missing Counts that = 0 in query results
    By dandhjohn in forum Queries
    Replies: 1
    Last Post: 01-29-2010, 11:28 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