Results 1 to 6 of 6
  1. #1
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47

    Query returning strange results when using 'MAX'

    I have a database that collates the scores from our local Aussie Rules football league. I needed to obtain the maximum score kicked for each particular Round. I was given advise to have two select queries as below:


    Code:

    SELECT Max(AusFootBall.P) AS MaxOfP, AusFootBall.Rd


    FROM AusFootBall
    GROUP BY AusFootBall.Rd;

    And then run the second query:


    Code:

    SELECT AusFootBall.*
    FROM AusFootBall INNER JOIN QueryAus1_GetMaxByRd
    ON AusFootBall.Rd = QueryAus1_GetMaxByRd.Rd
    WHERE (((AusFootBall.P)=[QueryAus1_GetMaxByRd]![MaxOfP]));

    I need to see the whole row that the Maximum score applies to, hence the second query.
    This worked exceptionally well except on the odd occasion I would receive data like the following:
    Rd Dn Team G B P Team2 Year
    1 1 Berwick 15 10 100 Noble Park 1998
    1 1 Souths 5 7 37 Wests 1981
    1 2 Hallam 12 19 81 Geelong 2010
    1 3 Cobram 5 7 37 St.Kilda 2001
    I found that if the highest score in Division 3 was 37 for example, then the result for Division 1 would show it's highest score and also a random score that matched the 37 from Division 3. Is there anyway to get rid of the unwanted score(s). It happened for more than one round. Thank you in advance.



  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Your understanding of Access exceeds everyone's

    understanding of Aussie Rules football.
    I may have a go in the morning if no one else has solved your problem...and the Scotch is gone.

  3. #3
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47
    Thank-you. That would be great.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    It should work but I am baffled by the Year field. Is this multi-year data? Does each year have Rd 1, 2, 3, etc? Query appears to be returning records from multiple years although the GROUP query is finding the Max disregarding the year. Is this what you want?

    Can you provide raw data? A spreadsheet would be adequate.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    coach32 is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Aug 2011
    Posts
    47

    re: Max Query

    I have attached a sample of the data.
    Yes, each year does have Rounds 1 through to 14.
    The scores cover years 1963 thorugh to 2011.
    The end result I would like is for the query to show the Maximum score from each Division for each Round.
    Attached Files Attached Files

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    The Max query is not what you posted. It has Dn as filter criteria (1 Or 2 Or 3) but with GROUP BY so the grouping includes the Dn field and returned 6 Max records for the combined fields of Rd and Dn. Change Dn to WHERE and only 2 Max records will return. Now Query2 returns two records instead of all 9.

    This returns the Max record of all years combined.

    Works with the limited sample provided.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Dataset returning different results
    By Juan23 in forum Programming
    Replies: 8
    Last Post: 09-16-2011, 03:03 PM
  2. Strange report results
    By DDows in forum Reports
    Replies: 5
    Last Post: 01-10-2011, 06:43 PM
  3. InStrRev returning unexpected results
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 12-07-2010, 01:04 PM
  4. Query Bug? Not returning consistent results
    By trb5016 in forum Queries
    Replies: 4
    Last Post: 06-15-2010, 12:00 PM
  5. Query not returning all of the results
    By velvettiger in forum Queries
    Replies: 4
    Last Post: 03-11-2010, 06:56 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