Ranking/Numbering Records in Query

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?
 
K

KARL DEWEY

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top