Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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 #tempfrom MyTableselect * from #tempdrop table #temp