S
scoobs1000
Guest
I am designing a database for a fishing club to keep track of the fishing competition scores (in MS Access XP).
I have three tables; Catch (containing date, boat, fish, fish weight), Boats (list of boats), Fish (list of fish types and how many points they are worth). The score is determined as follows; each species of fish is worth a different score (per 100g), the score for each boat is determined as the sum of the top 5 scoring fish for each species. i.e. the score for Boat1 is determined from the five heaviest flounder, snapper, crayfish, etc.
I have written the following query to do this:
The query works fine except when there are several fish with the same weight that are tied for fifth position. The TOP query returns all ties in Access SQL so I end up with six or seven fish returned which give a high score. I need to return only 5 fish even if there is a tie.
This seems to be possible in Oracle and Access Server using rownum or limit functions but these are not available in Access XP. Is there a way to limit the number of records returned by the subquery in Access XP?
I have three tables; Catch (containing date, boat, fish, fish weight), Boats (list of boats), Fish (list of fish types and how many points they are worth). The score is determined as follows; each species of fish is worth a different score (per 100g), the score for each boat is determined as the sum of the top 5 scoring fish for each species. i.e. the score for Boat1 is determined from the five heaviest flounder, snapper, crayfish, etc.
I have written the following query to do this:
Code:
SELECT Boats.Boatname, Catch.Date, Fish.Species, Catch.Weight, Fish.[Weighted points], [Weighted points]*[weight] AS [Points Awarded]
FROM Boats INNER JOIN (Fish INNER JOIN Catch ON Fish.ID = Catch.Fish) ON Boats.ID = Catch.Boat
WHERE (((Catch.Weight) In (SELECT TOP 5 Catch.Weight From Catch WHERE Catch.Fish = Fish.ID AND Boats.ID = Catch.Boat ORDER BY Catch.Weight DESC)))
ORDER BY Boats.Boatname, Fish.Species, Catch.Weight DESC;
The query works fine except when there are several fish with the same weight that are tied for fifth position. The TOP query returns all ties in Access SQL so I end up with six or seven fish returned which give a high score. I need to return only 5 fish even if there is a tie.
This seems to be possible in Oracle and Access Server using rownum or limit functions but these are not available in Access XP. Is there a way to limit the number of records returned by the subquery in Access XP?