S
Sophie
I help organize my school region's math competitions. I've been struggling
with some SQL for days, and would really appreciate some clear assistance
(for reluctant programmers!).
My form currently has two textboxes with Control Sources Total and
TeamName respectively. When I use the following SQL as the Form's Record
Source, everything works fine, giving me a result like... 155.6 Math
Marvels
SELECT TOP 1 Q1.TeamID, Q1.TeamName, Sum(Q1.Score) AS Total FROM
[qryStudent] AS Q1 WHERE (Q1.StudentID In ((SELECT Top 3 Q2.StudentID FROM
[qryStudent] As Q2 WHERE (Q2.TeamID = Q1.TeamID) ORDER BY Score DESC,
StudentID))) GROUP BY Q1.TeamID, Q1.TeamName ORDER BY Sum(Q1.Score) DESC,
Q1.TeamName;
But, what I really am trying to do is a bit different. I want my form to
show the Team winner based on the top 3 scores, then the Team winner based on
the top 4 scores, ... up to the Team winner based on the top 6 scores.
Something like...
Winner, top 3 scores 155.6 Math Marvels
Winner, top 4 scores 200.4 Math Marvels
Winner, top 5 scores 247.1 Group Groupies
Winner, top 6 scores 155.6 Calculus Canines
(we do this so that the organizers can have some flexibility with team
awards depending on the number of 'mathematicians' competing.)
I would really appreciate some help in setting this up. I can't figure out
where the SQL should go, or how the form should be set up, or how to get it
to loop through TOP 3 to TOP 6. I also need to produce the exact same info
in a report, but I imagine this will be handled the same as the form.
with some SQL for days, and would really appreciate some clear assistance
(for reluctant programmers!).
My form currently has two textboxes with Control Sources Total and
TeamName respectively. When I use the following SQL as the Form's Record
Source, everything works fine, giving me a result like... 155.6 Math
Marvels
SELECT TOP 1 Q1.TeamID, Q1.TeamName, Sum(Q1.Score) AS Total FROM
[qryStudent] AS Q1 WHERE (Q1.StudentID In ((SELECT Top 3 Q2.StudentID FROM
[qryStudent] As Q2 WHERE (Q2.TeamID = Q1.TeamID) ORDER BY Score DESC,
StudentID))) GROUP BY Q1.TeamID, Q1.TeamName ORDER BY Sum(Q1.Score) DESC,
Q1.TeamName;
But, what I really am trying to do is a bit different. I want my form to
show the Team winner based on the top 3 scores, then the Team winner based on
the top 4 scores, ... up to the Team winner based on the top 6 scores.
Something like...
Winner, top 3 scores 155.6 Math Marvels
Winner, top 4 scores 200.4 Math Marvels
Winner, top 5 scores 247.1 Group Groupies
Winner, top 6 scores 155.6 Calculus Canines
(we do this so that the organizers can have some flexibility with team
awards depending on the number of 'mathematicians' competing.)
I would really appreciate some help in setting this up. I can't figure out
where the SQL should go, or how the form should be set up, or how to get it
to loop through TOP 3 to TOP 6. I also need to produce the exact same info
in a report, but I imagine this will be handled the same as the form.