Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old March 28th, 2004, 09:30 PM
hohum hohum is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Where You Live
Posts: 2 hohum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to hohum
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:
Original - php Code
  1. UPDATE MissionStats SET PPG = (IF(win = 1, 1000, 0)+hostieescorts*500+hostiesecures*500+hostiesteal  s*750+rkills*150-rdeaths*50)


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

Reply With Quote
  #2  
Old March 28th, 2004, 09:59 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
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.

Reply With Quote
  #3  
Old March 28th, 2004, 11:36 PM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
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

Reply With Quote
  #4  
Old March 28th, 2004, 11:38 PM
hohum hohum is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Where You Live
Posts: 2 hohum User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to hohum
RE: Handicap Scoring

didn't notice i wasn't logged in, sry, i posted the above

Reply With Quote
  #5  
Old March 29th, 2004, 12:09 PM
Blindeddie Blindeddie is offline
Codewalkers Regular (2000 - 2499 posts)
 
Join Date: Apr 2007
Location: NJ - USA
Posts: 2,152 Blindeddie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 4
RE: Handicap Scoring

In order to restrict it to the last 50 games, you would need to also order it by date descending.

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Handicap Scoring


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT