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)
 SQL statement problem?

Author  Topic 

goldfish
Starting Member

2 Posts

Posted - 2004-04-27 : 00:55:25
Write an SQL list the names of the top 5 players and their scores, sorted by score, along with the rank for each player
Table given:
PlayerID (int) PlayerName varchar(30) Score (int)
1 Bench 20
2 Perez 35
3 Morgan 35
4 Concepcion 10
5 Rose 18
6 Foster 44
7 Geronimo 18

And this is the expected result:
RankNo PlayerName Score
1 Foster 44
2 Perez 35
2 Morgan 35
4 Bench 20
5 Rose 18
5 Geronimo 18

I don't know how to create the RankNo column which will be increased in such a behavior.

Anybody knows? Please help...



Goldfish

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-04-27 : 01:37:09
http://www.sqlteam.com/item.asp?ItemID=6398

A search for "Rank" on the front page of SQLTeam finds this answer



Damian
Go to Top of Page

goldfish
Starting Member

2 Posts

Posted - 2004-04-27 : 02:20:54
Thanks so much! Damian

Goldfish
Go to Top of Page
   

- Advertisement -