D
Dennis Snelgrove
I've got a database for a yearly competition wherein there are a number of
events, each of which has a score attached. As part of the end-of-contest
summarizing, I've got to generate a report based on team totals. I could do
this easily enough with an aggregate query, except for the fact that each
team could have a different number of members. The logic applied to make it
fair is to find out the size of the smallest team, then take the highest
scores from each team for the same number of people. For example, if the
smallest team has 4 members, then for each team we need to add up the 4
largest scores. I must be missing something, because I can't for the life of
me come up with the SQL to achieve this.
My tables look like this:
tblPlayer
PlayerID - autonumber PK
FirstName
LastName
Team
tblEvent
EventID - autonumber PK
EventName
tblPlayer_Event_Intersect
PlayerID FK
EventID FK
Score
(The PK is a combination of PlayerID and EventID)
Any insights or suggestions are really appreciated.
events, each of which has a score attached. As part of the end-of-contest
summarizing, I've got to generate a report based on team totals. I could do
this easily enough with an aggregate query, except for the fact that each
team could have a different number of members. The logic applied to make it
fair is to find out the size of the smallest team, then take the highest
scores from each team for the same number of people. For example, if the
smallest team has 4 members, then for each team we need to add up the 4
largest scores. I must be missing something, because I can't for the life of
me come up with the SQL to achieve this.
My tables look like this:
tblPlayer
PlayerID - autonumber PK
FirstName
LastName
Team
tblEvent
EventID - autonumber PK
EventName
tblPlayer_Event_Intersect
PlayerID FK
EventID FK
Score
(The PK is a combination of PlayerID and EventID)
Any insights or suggestions are really appreciated.