Go to Post ...after all these years Dean is still on message, and the message still resonates. - Richard Wallace [more]
Home
Go Back   Chief Delphi > FIRST > General Forum
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 18-10-2008, 02:40
Nibbles Nibbles is offline
Interstellar Hitchhiker
AKA: Austin Wright
FRC #0498 (Cobra Commanders)
Team Role: Alumni
 
Join Date: Jan 2008
Rookie Year: 2003
Location: Arizona
Posts: 103
Nibbles is just really niceNibbles is just really niceNibbles is just really niceNibbles is just really niceNibbles is just really nice
Re: FIRST Ranking Software

Five table SQL join. Fun. (Four is all you need, actually, and it would be six if I only knew $eventid but not $season) This database is structured such that a table can contain data for multiple seasons and events, $eventid and $season are substituted for the database-specific event ID and year, respectively. It what I use for my scouting program to update team rankings.

The IF function is specific to MySQL, any other database will need to replace it with a standard IF/ELSE or CASE statment.

Code:
SELECT
 t.teamnum,
 SUM(IF(a.score>o.score,1,0)) AS won,
 SUM(IF(a.score<o.score,1,0)) AS loss,
 SUM(IF(a.score=o.score,1,0)) AS tie,
 SUM(CASE
   WHEN a.score>o.score THEN 2
   WHEN a.score=o.score THEN 1
   WHEN a.score<o.score THEN 0
 END) AS qualify,
 SUM(CASE
   WHEN a.score>=o.score THEN a.points
   WHEN a.score<o.score THEN o.score
 END)/SUM(1) AS ranking,
 SUM(1) AS matches
FROM
 team t LEFT OUTER JOIN team_event u ON t.teamnum=u.teamnum,
 team_match m, alliance a, alliance o
WHERE m.surrogate=0 AND m.disqualified=0
 AND t.teamnum=m.teamnum
 AND a.matchid=m.matchid
 AND o.matchid=m.matchid
 AND a.alliance=m.alliance
 AND o.alliance!=m.alliance
 AND t.season=$season
 AND u.eventid=$eventid
 AND m.eventid=u.eventid
 AND a.eventid=u.eventid
 AND o.eventid=u.eventid
GROUP BY t.teamnum
__________________
Help standardize match data! Use the XML interchange format. (Specification page)
AAA_awright on Freenode IRC chat. (Join us at ##FRC on chat.freenode.net, or in your browser)
Reply With Quote
Reply


Thread Tools
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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
The FIRST Software Repository roboticsguy1988 Programming 0 30-03-2008 23:08
**FIRST EMAIL**/FIRST Announces PTC Collaboration Software Sponsorship! Mark McLeod FIRST E-Mail Blast Archive 29 19-12-2007 16:58
FIRST: Fwd: SolidWorks Software support for US First Teams chris31 FIRST E-Mail Blast Archive 8 24-04-2007 15:09
FIRST Software Repository - updated roboticsguy1988 Technical Discussion 0 04-11-2006 22:54


All times are GMT -5. The time now is 15:27.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi