Jump to content

Recommended Posts

Hello All,

 

I am trying to plan a project in which a leader board will be generated from a set of results within a SQL database. The only thing that I am unsure about is when I list the results I want them in order of win rate (which will be a percentage) and if more than one person has the same percentage it will show something like this;

 

Rank Name Percentage

1 Bob 100%

2 Sam 98%

  James 98%

  Jamie  98%

5 Tom 26%

 

As you can see i want it to identify draws like this. My percentage is also to two decimals but that should make much difference, on results which have the same percentage i will list them in order of name.

 

Can anyone provide any examples or point me in the right direction.

 

Thanks

Sam

Link to comment
https://forums.phpfreaks.com/topic/207695-rankingsleader-boards/
Share on other sites

Hi,

 

Exmaple replace the % sign to empty in the Percentage column, and then convert it to decimal. After that you can order it as an integer, like that:

 

SELECT Rank, Name, Percentage FROM leader_board ORDER BY CONVERT(REPLACE(a, '%', ''),DECIMAL), Name;

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.