Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Other Forums
 MS Access
 Double Inner Select

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-03-16 : 08:19:25
Tony writes "Here is my Query:

SELECT Races.LeagueID, Ranked.AthleteID, Ranked.RaceID, Ranked.Time,
(SELECT Count([Time]) from (SELECT y.RaceID, y.Time FROM Results AS y WHERE y.RaceID = Ranked.RaceID ORDER BY y.Time)
AS x Where [x]![Time] < [Ranked].[Time]) +1
AS Ranking
FROM Races RIGHT JOIN Results AS Ranked ON Races.RaceID = Ranked.RaceID
WHERE (((Races.LeagueID)=[L]))
ORDER BY Ranked.AthleteID, Ranked.RaceID;

The query works apart from 1 thing. The WHERE clause "WHERE y.RaceID = Ranked.RaceID" asks for input of Ranked.RaceID instead of using the current rows Ranked.RaceID

The results I am looking for are to show a list of Athletes sorted by Athlete by RaceID showing their Time and (the bit that doesn't work) their Position in the race.

I am sure their is a easy answer, I just can't fathom it out.

Thankyou"
   

- Advertisement -