Results 1 to 8 of 8
  1. #1
    ohi is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2009
    Posts
    5

    Query is showing invalid totals (due to multiple records)

    I know what the problem is, but I'm not sure how to fix it.

    Here is the query in question:


    Code:
    SELECT qry_cfu_MainSelect.[Case Number], qry_cfu_MainSelect.Examiner, Count(qry_cfu_HD.Size) AS CountOfSize1, Count(qry_cfu_LooseDrives.Size) AS CountOfSize2, Sum(qry_cfu_HD.Size) AS SumOfSize1, Sum(qry_cfu_LooseDrives.Size) AS SumOfSize2
    FROM (qry_cfu_MainSelect INNER JOIN qry_cfu_LooseDrives ON qry_cfu_MainSelect.[Case Number] = qry_cfu_LooseDrives.[Case Number]) INNER JOIN qry_cfu_HD ON qry_cfu_MainSelect.[Case Number] = qry_cfu_HD.[Case Number]
    GROUP BY qry_cfu_MainSelect.[Case Number], qry_cfu_MainSelect.Examiner;
    and there is also a visual sample attached.

    The problem is this. There are multiple records in the table and it's doubling the counts instead of showing the true totals.

    Case Number 09100 and 09102 are showing correctly, however 09101 is incorrect.

    CountOfSize 2 (second column) is 2 and should be 1
    Sum of Size2 (4th column) is 8 and should be 4. It's doubled because there are 2 records attached to case number 09101.

    I really hope I made sense of all of this. Anyone have a solution for me? Any help is greatly appreciated! TYIA.

  2. #2
    Graysworld is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    6
    Hi guys. I'm really interested in the answer to this. There have been a number of questions along this line, but I can't find any post with a reply. Can anyone help?

    Ohi, did you solve this, and if so, how?

  3. #3
    ohi is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2009
    Posts
    5
    After much trial and error, yes I was able to finally get it to work. Here's the code I used.


    Code:
    SELECT qry_MainSum.[Case Number], qry_MainSum.Examiner, qry_MainSum.[Date of Assignment], qry_LooseDriveSums.[Number ofLoose Drives], qry_LooseDriveSums.[Loose Drive Total], qry_HDSums.[Number of HD], qry_HDSums.[HD Total], Nz([Loose Drive Total])+Nz([HD Total]) AS [Total Processed]
    FROM (qry_MainSum LEFT JOIN qry_LooseDriveSums ON qry_MainSum.[Case Number] = qry_LooseDriveSums.[Case Number]) LEFT JOIN qry_HDSums ON qry_MainSum.[Case Number] = qry_HDSums.[Case Number];
    I then had an issue with Count and Sum showing no values due to some of the data being blank, but Nz in the calculations fixed that.

    I'm sorry I really can't be more specific on how I fixed it, I just was able to by trial and error like I said.

  4. #4
    Graysworld is offline Novice
    Windows Vista Access 2007
    Join Date
    Dec 2009
    Location
    Melbourne, Australia
    Posts
    6
    Thanks Ohi

  5. #5
    ohi is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2009
    Posts
    5
    No problem, hope this can help you.

  6. #6
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So ohi, are you ready to follow the link in my sig and mark this thread as Solved?

  7. #7
    ohi is offline Novice
    Windows XP Access 2002
    Join Date
    Nov 2009
    Posts
    5
    Apologize, thread marked solved

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    No apology necessary. Thanks.

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

Similar Threads

  1. Query - using Max Totals with Criteria
    By mslieder in forum Access
    Replies: 1
    Last Post: 06-19-2013, 06:02 AM
  2. Replies: 3
    Last Post: 09-29-2009, 07:08 AM
  3. Replies: 0
    Last Post: 06-07-2007, 02:33 PM
  4. query - totals
    By mslieder in forum Access
    Replies: 0
    Last Post: 02-22-2006, 06:11 PM
  5. Null Values not showing up in a Query
    By Valli in forum Queries
    Replies: 0
    Last Post: 01-04-2006, 03:53 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