Good day:
I have a subquery that I have created to try and get the top 5 scores for a team.
Each team could have 7 members and they all could have the same score (for example 25).
I developed this code following principles from this forum.
SELECT tblParticipant.Division, tblParticipant.TeamName, tblParticipant.County, tblParticipant.Team, tblParticipant.Score, tblParticipant.TO20, tblParticipant.TO21, tblParticipant.TO22, tblParticipant.TO23, tblParticipant.TO24, tblParticipant.TO25, tblParticipant.ShooterID, tblParticipant.FName, tblParticipant.LName
FROM tblParticipant
WHERE tblParticipant.Score IN
(SELECT TOP 5 Score
FROM tblParticipant AS Dupe
Where Dupe.TeamName = tblParticipant.TeamName
ORDER BY Dupe.Score DESC)
ORDER BY tblParticipant.Division, tblParticipant.TeamName, tblParticipant.Score DESC , tblParticipant.TO20 DESC , tblParticipant.TO21 DESC , tblParticipant.TO22 DESC , tblParticipant.TO23 DESC , tblParticipant.TO24 DESC , tblParticipant.TO25 DESC;
Any ideas why it won't give me just the top 5 from each team?
Thanks
I have a subquery that I have created to try and get the top 5 scores for a team.
Each team could have 7 members and they all could have the same score (for example 25).
I developed this code following principles from this forum.
SELECT tblParticipant.Division, tblParticipant.TeamName, tblParticipant.County, tblParticipant.Team, tblParticipant.Score, tblParticipant.TO20, tblParticipant.TO21, tblParticipant.TO22, tblParticipant.TO23, tblParticipant.TO24, tblParticipant.TO25, tblParticipant.ShooterID, tblParticipant.FName, tblParticipant.LName
FROM tblParticipant
WHERE tblParticipant.Score IN
(SELECT TOP 5 Score
FROM tblParticipant AS Dupe
Where Dupe.TeamName = tblParticipant.TeamName
ORDER BY Dupe.Score DESC)
ORDER BY tblParticipant.Division, tblParticipant.TeamName, tblParticipant.Score DESC , tblParticipant.TO20 DESC , tblParticipant.TO21 DESC , tblParticipant.TO22 DESC , tblParticipant.TO23 DESC , tblParticipant.TO24 DESC , tblParticipant.TO25 DESC;
Any ideas why it won't give me just the top 5 from each team?
Thanks