Results 1 to 8 of 8
  1. #1
    jpawson74 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5

    Group by pulling incorrect results

    Hi all, i'm struggling with the simplest of queries, i'm using one table and grouping on two fields.

    Table
    ID Term


    123 84
    123 84
    123 84

    Query returns
    ID Term
    123 84
    123 12

    How on earth is it possible to return two records and one with 12 as the term when it doesn't exist against ID 123

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I don't see how it could. Can you post a sample db here that does this?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jpawson74 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    Unfortunately the tables in question are odbc linked so i'm unable to post a sample db at present. My colleague has tried the same query on his pc and the same occurs. Select queries without groupings produce the correct results but as soon as you add the groupings this strange result occurs, same happens if you change the query to a make table query. Absolutely stumped.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Does this return anything?

    SELECT ID, Term
    FROM TableName
    WHERE ID = 123 And Term = 12

    Replacing with the appropriate names/values of course.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jpawson74 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    Yes it returns one record but strangely enough it brings back the term 36

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    That seems impossible. I suspected there was a record with 12, but I can't imagine how a record with 36 could be returned by that query. Can you import the relevant table into a db and post it here? We don't want any sensitive data of course, but something is wacky in the data here.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    jpawson74 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    I've signed off for the day so will try and upload a file tomorrow, many thanks for your help.

  8. #8
    jpawson74 is offline Novice
    Windows XP Access 2003
    Join Date
    Mar 2012
    Posts
    5
    Update, when importing the table in question to SQL Server this displays the correct data (2 records with term of 36 and 1 record with 12) but if I link to this newly created table in SQL Server from access odbc this reverts back to displaying all 3 records terms of 36 so it must be an odbc issue and not a data issue.

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

Similar Threads

  1. Access Min Max Comparison Yielding Incorrect Results
    By MetalCheese in forum Programming
    Replies: 6
    Last Post: 12-06-2011, 04:29 PM
  2. Incorrect Sums
    By Azyrus in forum Reports
    Replies: 6
    Last Post: 06-26-2011, 04:27 PM
  3. Group query results
    By shak2 in forum Access
    Replies: 7
    Last Post: 10-20-2010, 02:41 PM
  4. Incorrect sorting in report.
    By jonesy29847 in forum Reports
    Replies: 2
    Last Post: 06-16-2010, 05:56 PM
  5. columns for group detail but not group header?
    By Coolpapabell in forum Reports
    Replies: 0
    Last Post: 08-21-2009, 08:53 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