Ranking/Numbering Records in Query

  • Thread starter Thread starter joel_falk
  • Start date Start date
J

joel_falk

I am trying to create a database that lets me keep track of running
performances and rank them against one another. I have created a
table named Races that contains: runner_id, racename, date, distance,
and seconds.

I want to select these records grouped by seconds (ascending) and then
assign a numberic ranking to each records. Surely this must be
possible, right?
 
Try this ---
SELECT runner_id, racename, date, distance, seconds, (SELECT COUNT(*)
FROM [YourTable] T1
WHERE T1.seconds <= T.seconds) AS Rank
FROM [YourTable] AS T
ORDER BY seconds;

Seems like you need distance/seconds.
 
Back
Top