Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL Volleyball Standings
    primarykey
    data
    text
    <p>I have a database table full of game by game results and want to know if I can calculate the following:</p> <ul> <li>GP (games played)</li> <li>Wins</li> <li>Loses</li> <li>Points (2 points for each win, 1 point for each lose)</li> </ul> <p>Here is my table structure:</p> <pre><code>CREATE TABLE `results` ( `id` int(10) unsigned NOT NULL auto_increment, `home_team_id` int(10) unsigned NOT NULL, `home_score` int(3) unsigned NOT NULL, `visit_team_id` int(10) unsigned NOT NULL, `visit_score` int(3) unsigned NOT NULL, `tcl_id` int(3) unsigned NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=7 ; </code></pre> <p>And a few testing results:</p> <pre><code>INSERT INTO `results` VALUES(1, 1, 21, 2, 25, 68); INSERT INTO `results` VALUES(2, 3, 21, 4, 17, 68); INSERT INTO `results` VALUES(3, 1, 25, 3, 9, 68); INSERT INTO `results` VALUES(4, 2, 7, 4, 22, 68); INSERT INTO `results` VALUES(5, 1, 19, 4, 20, 68); INSERT INTO `results` VALUES(6, 2, 24, 3, 26, 68); </code></pre> <p>Here is what a final table would look something like this (results are not completely accurate):</p> <pre><code>+-------------------+----+------+-------+--------+ | Team Name | GP | Wins | Loses | Points | +-------------------+----+------+-------+--------+ | Spikers | 4 | 4 | 0 | 8 | | Leapers | 4 | 2 | 2 | 6 | | Ground Control | 4 | 1 | 3 | 5 | | Touch Guys | 4 | 0 | 4 | 4 | +-------------------+----+------+-------+--------+ </code></pre> <p>Need to add WHERE clause for <pre><code>tcl_id</code></pre> like so:</p> <p>WHERE results.tcl_id = 68</p> <p>Thank you in advance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload