Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19
  1. #16
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    I have a quick question on this.



    Let's say the typical case is that each person has 3 races and I code to eliminate the min value, I assume that if a specific person only has 2 races, it will eliminate the lower of those 2.

    What happens if a person only has 1 race? Does it eliminate that one and return nothing?

    Is there any way to control it where I say if there are 3, provide the best 2, if there are 2 provide both of those, if there is 1, give me that 1?

  2. #17
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    Here is the SQL from my current Query:

    SELECT RS1.RCTrack, RS1.RCDate, RS1.RCRace, RS1.horse,
    Sum([2Fsprint4Froute])/Count([2Fsprint4Froute]) AS [AVG],
    Sum([4Fsprint6Froute])/Count([4Fsprint6Froute]) AS AVG2
    FROM RS1
    WHERE (((RS1.[2Fsprint4Froute])<>(select min([x].[2Fsprint4Froute]) FROM [RS1] X where [x].[horse] = [RS1].[horse])))
    GROUP BY RS1.RCTrack, RS1.RCDate, RS1.RCRace, RS1.horse;

    It takes the group, eliminates the minimum record, and averages a couple of fields of the remaining records. Here's the problem. If the minimum value occurs more than one time, it eliminates all of them. So say I have 4 values that are 11, 10, 9, 8 and I want to eliminate the minimum, that should eliminate the 8, leave me the average of 11, 10 and 9. Perfect. If however, the 4 values are 11, 10, 9, 9 it eliminates both 9s and averages the 11 and 10 when I really want it to average 11, 10 ,and 9. How do I get it to only eliminate a single occurrence?

    Thanks

  3. #18
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    Does anyone see the syntax error here?

    I have a table called RaceFlowC2a with group of records. All I want to do is eliminate the record from each group with the maximum value (only 1 occurrence if there is ore than one).

    The Table will be grouped on Track, [Date Race], and [Race Num]

    The field I am interested in is MinOfFRRating. From the group I want to eliminate the record with the maximum value in MinOfFRRating. If there is a better/easier way I am all ears. I've been able to create queries similar to this in the past, but something is miss here.



    SELECT RaceFlowC2a.Track, RaceFlowC2a.[Date Race], RaceFlowC2a.[Race Num], RaceFlowC2a.MinOfFRRating
    FROM RaceFlowC2a
    WHERE ((([RaceFlowC2a].[MinOfFRRating] <>(select max([X].[RaceFlowC2a].[MinOfFRRating])
    FROM [RaceFlowC2a] X
    where
    [x].[RaceFlowC2a].[Track] = [RaceFlowC2a].[Track] and [x].[RaceFlowC2a].[Date Race] = [RaceFlowC2a].[Date Race] and [x].[RaceFlowC2a].[Race Num] = [RaceFlowC2a].[Race Num] and [x].[RaceFlowC2a].[MinOfFRRating] = [RaceFlowC2a].[MinOfFRRating])))
    GROUP BY [RaceFlowC2a].[Track], [RaceFlowC2a].[Date Race], [RaceFlowC2a].[Race Num];

  4. #19
    wcrimi is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    142
    I'm still struggling with this trying various approaches.

    This is the latest.

    I have a table with 4 fields

    [Track]
    [Date Race]
    [Race Num]
    [MinOfFRRating]

    I want to group on [Track], [Date Race] and exclude the max value MinOfFRRating from the output (preferably only a single occurrence if there is more than 1 with the same max value)

    The following code is not excluding max value of each group. I believe it's excluding the max value of the entire table.

    SELECT Track, [Date Race], Avg(MinOfFRRating) AS AvgOfMinOfFRRating, Count(MinOfFRRating) AS CountOfMinOfFRRating
    FROM RaceFlowC2a
    WHERE (((MinOfFRRating)<>(select max([X].[MinOfFRRating])
    FROM [RaceFlowC2a] X
    where
    [x].[Track] = [Track] and [x].[Date Race] = [Date Race])))
    GROUP BY Track, [Date Race];

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 09-17-2015, 10:23 PM
  2. Eliminating Repetitive Data in a query/report
    By Ranger7913 in forum Queries
    Replies: 3
    Last Post: 11-03-2014, 12:40 PM
  3. Replies: 4
    Last Post: 04-22-2014, 08:23 AM
  4. Replies: 2
    Last Post: 01-27-2012, 09:49 PM
  5. eliminating pop up boxes asking for a value
    By REBBROWN in forum Queries
    Replies: 3
    Last Post: 10-13-2010, 11:50 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