Results 1 to 12 of 12
  1. #1
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7

    Access 2007 Brainfade : Can not think of method to filter certain results


    Greetings one and all !

    I have a database in Access 2007 which has been built to score a shooting match. The database calculates the results in different categories and calibres etc and produces several corresponding reports. Everything is working fine except for one set of results which I can not get my head around.

    I have a query which combines the best pistol score with the best rifle score which is easy enough, but some competitors enter twice with different calibres and the best score of each entry needs to be combined.

    The query puts the scores together in four combinations :

    Pistol1 + Rifle1
    Pistol1 + Rifle2
    Pistol2 + Rifle1
    Pistol2 + Rifle2

    The highest scoring set needs to be retained, and the two "false results" binned and the remaining result retained. So for example :

    Pistol 1 = 1000 Points
    Pistol 2 = 800
    Rifle 1 = 600
    Rifle 2 = 500

    I currently get 4 results :

    a) 1000 + 600 = 1,600 points
    b) 1000 + 500 = 1,500
    c) 800 + 600 = 1,400
    d) 800 + 500 = 1,300

    The best result is obviously a. Then b and c need to be eliminated leaving d as the second result.

    There are roughly 100 records in the query, some with double entries some with single.

    I can not think of a way to efficiently do this.

    Any thoughts ?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    What's best depends on how you have your data set up. In absence of any info on that and based on what you've shown, a query that returns TOP 2 from your query ought to work though.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7
    I can not use TOP 2 because the second combination is to be discarded. I have a table with Shooter info, a table with registration info, a table with result data and a query that calculates results.

    The output from this query works fine for single entrants, I just can not see how I will filter out the "phantom" results from people who enter twice

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    Why does query result in 4 combinations? Post the SQL.

    Shooters won't have more than two for each category? Only two categories? Max() and Min() on the raw data don't get what you want?

    MaxPistol: Max(IIf(Category="Pistol", Points, Null))
    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
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Well, I though this was your data
    I currently get 4 results :

    a) 1000 + 600 = 1,600 points
    b) 1000 + 500 = 1,500
    c) 800 + 600 = 1,400
    d) 800 + 500 = 1,300
    That's the excuse I'm sticking with!

  6. #6
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7
    Here is the SQL :

    SELECT Tbl_Shooters.Prénom, Pistolet.Tireur, [Nom] & " " & [Prénom] AS FullName, Pistolet.CommandeID AS PistInscr, PistoletResult.Results AS PisRes, Pistolet.Article AS PistCal, PistoletResult.Abbr AS PCalibre, Rifle.CommandeID AS RifInscr, Rifle.Article AS RifCal, RifleResult.Abbr AS RCalibre, RifleResult.Results AS RifRes, [RifRes]+[PisRes] AS ResultatCombi
    FROM (Tbl_Shooters INNER JOIN (Tbl_Commandes AS Rifle INNER JOIN Qry_ResultatsIndividuels AS RifleResult ON Rifle.CommandeID = RifleResult.CommandeID) ON Tbl_Shooters.TireurID = Rifle.Tireur) INNER JOIN (Tbl_Commandes AS Pistolet INNER JOIN Qry_ResultatsIndividuels AS PistoletResult ON Pistolet.CommandeID = PistoletResult.CommandeID) ON Tbl_Shooters.TireurID = Pistolet.Tireur
    WHERE (((PistoletResult.Results)>0) AND ((Pistolet.Article)=1 Or (Pistolet.Article)=2) AND ((Rifle.Article)=3 Or (Rifle.Article)=4) AND ((RifleResult.Results)>0));

  7. #7
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7
    Here is a screen shot of the problem :

    Click image for larger version. 

Name:	Capture.JPG 
Views:	15 
Size:	25.0 KB 
ID:	23431

    In this instance, the second line is the "best" combination and the fourth line is the "worst". the other two need to be filtered out as they are not real.

  8. #8
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7
    Quote Originally Posted by Micron View Post
    Well, I though this was your data

    That's the excuse I'm sticking with!
    It is a good excuse ! I guess I have not been very clear Those results are from a single competitor, I have about 80 competitors.

  9. #9
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    That's what I thought until I saw the second set of data.

    Did you consider suggestion in post 4? Something like:

    SELECT Results.Shooter, Max(IIf([Category]="Pistol",[Points],Null)) AS MaxPistol, Max(IIf([Category]="Rifle",[Points],Null)) AS MaxRifle, Min(IIf([Category]="Pistol",[Points],Null)) AS MinPistol, Min(IIf([Category]="Rifle",[Points],Null)) AS MinRifle
    FROM Results
    GROUP BY Results.Shooter;
    Last edited by June7; 01-16-2016 at 11:00 PM.
    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.

  10. #10
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,778
    Looks like a good solution. But did you mean Min as Min?
    Max(IIf([Category]="Rifle",[Points],Null)) AS MinRifle
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,894
    Ooops, copy/paste strikes again. That second Max function for Rifle should be Min. I edited post.
    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.

  12. #12
    Jack Russel is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2016
    Posts
    7
    Hi Guys,

    Thanks very much for the help, sorry I did not get back to you sooner, I dropped the project for a while and have only just got back to it. You suggestions worked perfectly ! Thanks again.

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

Similar Threads

  1. Replies: 0
    Last Post: 08-11-2014, 12:25 PM
  2. Replies: 1
    Last Post: 08-16-2012, 01:51 PM
  3. Replies: 3
    Last Post: 07-19-2012, 09:27 AM
  4. Replies: 1
    Last Post: 06-21-2012, 07:58 PM
  5. Replies: 3
    Last Post: 11-17-2010, 05:21 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