I
Irene
Hi all,
Well, I managed to get the list of the best TOP <n> athletes in a
certain competition type (in this example is "Triathlon").
(Thanks to Michel and his page:
http://www.mvps.org/access/queries/qry0020.htm)
----
Athletics database. Tables: Athletes, Competitions, Scores,
CompetitionTypes.
SELECT Athletename, P.Score, CompetitionDate, CompetitionPlace
FROM ((Scores AS P INNER JOIN [SELECT TOP 10 AthleteID,Max(Score) as
MP FROM Scores INNER JOIN Competitions ON
Competitions.CompID=Scores.CompID WHERE CompType='triathlon' GROUP BY
AthleteID]. AS Q ON (P.AthleteID=Q.AthleteID) AND (P.Score=Q.MP))
INNER JOIN Competitions ON Competitions.CompID=P.CompID) INNER JOIN
Athletes ON Athletes.AthleteID=P.AthleteID
ORDER BY P.Score DESC;
----
I have still a little problem when the same athlet reaches the same
score in two or more different competitions. In this case, all the
competitions are listed. This is not what I want, I would like to list
the first best result of each athlet, so to say if the same score has
been reached on 12.Aug.2002 and 23.Apr.2003, just the oldest date's
competition should be listed.
I have tried to modify the given query without success.
Ok, if you find a bit of time to help me many thanks, otherwise have a
nice weekend!
Irene
Well, I managed to get the list of the best TOP <n> athletes in a
certain competition type (in this example is "Triathlon").
(Thanks to Michel and his page:
http://www.mvps.org/access/queries/qry0020.htm)
----
Athletics database. Tables: Athletes, Competitions, Scores,
CompetitionTypes.
SELECT Athletename, P.Score, CompetitionDate, CompetitionPlace
FROM ((Scores AS P INNER JOIN [SELECT TOP 10 AthleteID,Max(Score) as
MP FROM Scores INNER JOIN Competitions ON
Competitions.CompID=Scores.CompID WHERE CompType='triathlon' GROUP BY
AthleteID]. AS Q ON (P.AthleteID=Q.AthleteID) AND (P.Score=Q.MP))
INNER JOIN Competitions ON Competitions.CompID=P.CompID) INNER JOIN
Athletes ON Athletes.AthleteID=P.AthleteID
ORDER BY P.Score DESC;
----
I have still a little problem when the same athlet reaches the same
score in two or more different competitions. In this case, all the
competitions are listed. This is not what I want, I would like to list
the first best result of each athlet, so to say if the same score has
been reached on 12.Aug.2002 and 23.Apr.2003, just the oldest date's
competition should be listed.
I have tried to modify the given query without success.
Ok, if you find a bit of time to help me many thanks, otherwise have a
nice weekend!
Irene