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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How rank people

Author  Topic 

Rauken
Posting Yak Master

108 Posts

Posted - 2005-05-03 : 08:19:08
I have a db that contains people and tests and test results. I want to run a sql statement and get people ordered by their test result and a new field, rank. Highest testscore gives rank 1 and so on.. Is it possible to do in a select statement?

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-05-03 : 08:22:54
easiest to do with a temp table:

select identity(int, 1, 1) as rank, col1, col2, ...
into #temp
from MyTable

select * from #temp

drop table #temp


Go with the flow & have fun! Else fight the flow
Go to Top of Page

Rauken
Posting Yak Master

108 Posts

Posted - 2005-05-03 : 08:38:19
Thanks for the very fast answer!!
Go to Top of Page
   

- Advertisement -