Results 1 to 5 of 5
  1. #1
    Coheeba is offline Novice
    Windows XP Access 2007
    Join Date
    Sep 2011
    Posts
    1

    Calculating race finishing positions

    What I need is a way of calculating finishing positions.

    I need a way to make "Finish Place" = "1" for Teri in race 2, "2" for Hannah in race 2, "3" for Amos in race 2, and "4" for Tim in race 2 in the attached sheet.

    Let me know if you need anything further. I've been looking at this so long my brain hurts.

    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Search on "ranking" queries. Basically you use a subquery or a DCount() to count the number of records with a time <= to the current record. In your case the race number would be an additional criteria.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You can also, if your output is a report, simply put in a line count field on your report and order your race finishes by time, the line count field will properly number the finishing positions assuming your sort is what you want.

    I made a table called tblRaces, changed your TIME field to RACETIME and your RACE# field to RACENUM. TIME is a reserved word in access and you do not want to use it as a field name. Likewise # is a special character that has meaning in access so you do not want to use it in a field name either.

    This query does what you want:

    Code:
    SELECT tblRaces.RaceNum, tblRaces.Racer, tblRaces.RaceTime, DCount("*","tblRaces","[RaceNum] = " & [racenum] & " AND [RaceTime] <=  " & [racetime] & "") AS RacePlace
    FROM tblRaces
    ORDER BY tblRaces.RaceNum, tblRaces.Racer;
    Normally I try to stay away from Domain functions (Dsum, dcount, davg, etc) so consider what you need your final product to be, is it a list of races involving the same people and an overall winner based on placement in a series of races? if so you can do that on a report without using domain functions.

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Unless I'm missing something, using a field on the report would not handle ties correctly.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    You're right, if you just use a simple line count function. I just assumed there would be no ties, but it can still be done on a report if there are.

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

Similar Threads

  1. Replies: 1
    Last Post: 03-28-2011, 08:47 AM
  2. Calculating Dates
    By TC0126 in forum Queries
    Replies: 1
    Last Post: 02-23-2010, 08:13 PM
  3. Race Sports Time format
    By flebber in forum Database Design
    Replies: 0
    Last Post: 09-13-2009, 08:38 AM
  4. Calculating the sum of every four records.
    By Alanlives in forum Queries
    Replies: 0
    Last Post: 07-31-2009, 05:56 AM
  5. Calculating Values
    By Jahan in forum Queries
    Replies: 1
    Last Post: 07-09-2006, 09:15 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