G
Gina K
The following is the first subquery I’ve ever used. It’s coming very close
to what I want, except if there is a tie in the TimeResult field. What I'd
like is to assign a unique number (Rank) to each record in the group based on
TimeResult (ascending). If there is a tie in TimeResult, break that tie
alphabetically, i.e. if Smith and Jones are tied at 1120, then assign Jones
the lower rank.
Can anyone help me?
Thanks.
SELECT tblEventResults.fkAthlete, tblEventResults.fkMeetEventID,
tblEventResults.TimeResult, (SELECT Count(*) FROM tblEventResults AS T
WHERE T.TimeResult < tblEventResults.TimeResult AND T.fkMeetEventID =
tblEventResults.fkMeetEventID)+1 AS AutoPlace, tblMeetEvents.fkMeetID,
tblAthletes.School, tblEventResults.ResultType
FROM tblMeet INNER JOIN ((tblEventLookup INNER JOIN tblMeetEvents ON
tblEventLookup.EventName = tblMeetEvents.Event) INNER JOIN (tblAthletes INNER
JOIN tblEventResults ON tblAthletes.Athlete = tblEventResults.fkAthlete) ON
tblMeetEvents.MeetEventID = tblEventResults.fkMeetEventID) ON tblMeet.MeetID
= tblMeetEvents.fkMeetID
WHERE (((tblEventResults.ResultType)="Pre-Meet"))
ORDER BY tblEventResults.TimeResult, tblEventResults.fkAthlete;
to what I want, except if there is a tie in the TimeResult field. What I'd
like is to assign a unique number (Rank) to each record in the group based on
TimeResult (ascending). If there is a tie in TimeResult, break that tie
alphabetically, i.e. if Smith and Jones are tied at 1120, then assign Jones
the lower rank.
Can anyone help me?
Thanks.
SELECT tblEventResults.fkAthlete, tblEventResults.fkMeetEventID,
tblEventResults.TimeResult, (SELECT Count(*) FROM tblEventResults AS T
WHERE T.TimeResult < tblEventResults.TimeResult AND T.fkMeetEventID =
tblEventResults.fkMeetEventID)+1 AS AutoPlace, tblMeetEvents.fkMeetID,
tblAthletes.School, tblEventResults.ResultType
FROM tblMeet INNER JOIN ((tblEventLookup INNER JOIN tblMeetEvents ON
tblEventLookup.EventName = tblMeetEvents.Event) INNER JOIN (tblAthletes INNER
JOIN tblEventResults ON tblAthletes.Athlete = tblEventResults.fkAthlete) ON
tblMeetEvents.MeetEventID = tblEventResults.fkMeetEventID) ON tblMeet.MeetID
= tblMeetEvents.fkMeetID
WHERE (((tblEventResults.ResultType)="Pre-Meet"))
ORDER BY tblEventResults.TimeResult, tblEventResults.fkAthlete;