The following code selects the top 2 from a query:
As you can see from the "Where" clause, I have excluded a team that is shooting for "Honours Only". What I would prefer to do is as follows:
If a team shotting for Honours Only comes second, the query selects the next team in the list and displays that as well. I can then show that in the results. If the second and third place team are Honours Only but the fourth is not, the fourth team is actually the second place winner. Consequently, the query should display four records. (I hope that makes sense!)
I'm sure this can be done and I would be grateful if someone could show me how.
Best Regards
John
Code:
SELECT TOP 2 QryFibuaTeam_Crosstab.TxtUnit, QryFibuaTeam_Crosstab.Honours_Only, QryFibuaTeam_Crosstab.Total, ([8]+[9]+[10]+[11]) AS Practice1, ([12]+[13]+[14]+[15]) AS Practice2, QryFibuaTeam_Crosstab.[8], QryFibuaTeam_Crosstab.[12], QryFibuaTeam_Crosstab.[9], QryFibuaTeam_Crosstab.[13], QryFibuaTeam_Crosstab.[10], QryFibuaTeam_Crosstab.[14], QryFibuaTeam_Crosstab.[11], QryFibuaTeam_Crosstab.[15], IIf([fFibuaTeam]=True,"FIBUA","") AS Event
FROM QryFibuaTeam_Crosstab INNER JOIN QryFibuaTeam ON QryFibuaTeam_Crosstab.TxtUnit = QryFibuaTeam.TxtUnit
WHERE (((QryFibuaTeam_Crosstab.Honours_Only)=False))
ORDER BY QryFibuaTeam_Crosstab.Total DESC , ([8]+[9]+[10]+[11]) DESC , ([12]+[13]+[14]+[15]) DESC , QryFibuaTeam_Crosstab.[8] DESC , QryFibuaTeam_Crosstab.[12] DESC , QryFibuaTeam_Crosstab.[9] DESC , QryFibuaTeam_Crosstab.[13] DESC , QryFibuaTeam_Crosstab.[10] DESC , QryFibuaTeam_Crosstab.[14] DESC , QryFibuaTeam_Crosstab.[11] DESC , QryFibuaTeam_Crosstab.[15] DESC;
As you can see from the "Where" clause, I have excluded a team that is shooting for "Honours Only". What I would prefer to do is as follows:
If a team shotting for Honours Only comes second, the query selects the next team in the list and displays that as well. I can then show that in the results. If the second and third place team are Honours Only but the fourth is not, the fourth team is actually the second place winner. Consequently, the query should display four records. (I hope that makes sense!)
I'm sure this can be done and I would be grateful if someone could show me how.
Best Regards
John