High Scores Table

High Scores Table


I'm making an application that calculates the score of an user and places this in a highscores table. Now the problem is I can't really find a way to make the ranking work. At the moment this is my query: 

So what it should do is give the user a ranking based on the score they got. Also if 2 users share the same score they should also share the same ranking.

Any help would be appreciated, thanks :)

What's exactly the issue? Is it repeating the rank if the total is the same?

For that I guess the assignment of [Ranking] must be calculated using a subquery to decide whether it must be incremented or not.

You can work through the example here: https://docs.microsoft.com/en-us/sql/t-sql/functions/ranking-functions-transact-sql

Both RANK() and DENSE_RANK() should give you what you need, you just need to decide on the order increment you prefer.