samtwilliams Posted July 14, 2010 Share Posted July 14, 2010 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 More sharing options...
bh Posted July 14, 2010 Share Posted July 14, 2010 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; Link to comment https://forums.phpfreaks.com/topic/207695-rankingsleader-boards/#findComment-1085747 Share on other sites More sharing options...
samtwilliams Posted July 14, 2010 Author Share Posted July 14, 2010 Hi, Sorry i forgot to say i am storing the win data as decimal already, i plan to use the order by clause but i want the php to add the rank numbers on as the page is generated. but i want it to show liek the example dataset above. Sam Link to comment https://forums.phpfreaks.com/topic/207695-rankingsleader-boards/#findComment-1085748 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.