Raised This Month: $12 Target: $400
 3% 

Rank calculation / sql


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-20-2018 , 04:43   Rank calculation / sql
Reply With Quote #1

how to calculate the best rank in the plugin, if i want 3 parameters to be included?
here is the table, for example:



wins column, should be priority in calculation, but im thinking of adding 'players' to rank cuz i would like to award players who participated in cups where the amount of players were bigger, so it means there was less chance to everyone of winning

with just first two columns in calculation, it would be:

SELECT * FROM table_name ORDER BY MIN( wins/cups ) ASC LIMIT 15
if the syntax is even allright

thanks in advance..ps maybe it could be posted in offtopic thread dunno

and ofc any other but better math is welcomed
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 10-20-2018 at 05:05.
JocAnis is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 10-20-2018 , 07:53   Re: Rank calculation / sql
Reply With Quote #2

wins / cups * players ?
Kushfield is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-20-2018 , 08:44   Re: Rank calculation / sql
Reply With Quote #3

ye i guess its good, but then if player1 got zero wins as player2, but he played more cups+with more players, they'll be at the same result, zero...?
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Kushfield
Member
Join Date: Jan 2017
Location: Estonia
Old 10-20-2018 , 08:54   Re: Rank calculation / sql
Reply With Quote #4

ORDER BY (wins / cups * players) DESC, wins DESC, cups DESC

First orders all players by (wins / cups * players), then orders groups of players with the same score according to wins, finally orders groups of players still with the same score according to cups.
Kushfield is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-20-2018 , 09:05   Re: Rank calculation / sql
Reply With Quote #5

oh yeah, that what i wanted, thanks!
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 10-24-2018 , 08:47   Re: Rank calculation / sql
Reply With Quote #6

just in case anyone will need it:
Code:
SELECT * FROM ( SELECT *, (CAST( wins AS float )/CAST( cups AS float)) AS winns FROM cup_info ) ORDER BY winns*players DESC, cups DESC, wins DESC LIMIT 15;
withotu making int to float, too many 0 results were in table...so floating is the fix
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode