|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||||
|
|||||
|
Handicap Scoring
I am attempting to write a proper functionning code to calculate a handicap-type scoring system:
My objective is to take the 100 Last games (score PPG (points per game) sort in DESC order then ONLY add the BEST top 50 scores, then divide by 50 (click here http://www.superfriendsleague.com/phpBB2/missions.php?ID=1 ) to see where the PPG column comes into play; below is the code that i have to SET the PPG. php Code:
i hope someone understands what it is i'm looking for, i've been wracking my brains for weeks :s - btw, yes, i'm a PHP/SQL n00b See, i was thinking of something like: SELECT PPG from MissionStats order DESC LIMIT 100 AS PPGT UPDATE MissionStats SET HDCP SUM(PPGT LIMIT 50)/50 *PPGT just a temp field while waiting for the update to come & grab the scores* *HDCP is the field it will be updating for the handicap score* keep in mind, i'm a n00b, and don't even have the slightest idea as to whether or not this is even feasible TIA |
|
#2
|
|||
|
|||
|
RE: Handicap Scoring
you can use one sql query to get the Handicap (this is actually just an average) like so
select sum(PPG)/50 as APPG from MissionStats order by ppg desc limit 50 then you can just use the APPG value to do your update. Disclaimer: I tested this on a DB I have on my server to see if the query would fail. Since it did not, I am assuming that it gave me the average of the top 50 values in the field. Make sure you test and confirm that it is doing what you want before implementing it. |
|
#3
|
|||
|
|||
|
RE: Handicap Scoring
thx for the help, but it not restricting itself to the last 50 games, it's taking ALL games (above & beyond 50)
also, i was hoping to be able to restrict it to the LAST 100 games sort thos in DESC order the take the TOP 50 from the last 100 games & divide those by 50... guess it might be a stretch :s |
|
#4
|
|||
|
|||
|
RE: Handicap Scoring
didn't notice i wasn't logged in, sry, i posted the above
|
|
#5
|
|||
|
|||
|
RE: Handicap Scoring
In order to restrict it to the last 50 games, you would need to also order it by date descending.
|
![]() |
| Viewing: Codewalkers Forums > Other Technologies > Database Help > Handicap Scoring |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|