Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Team W L T PF PA PCT
- —————————————————————————————————
- Team1 7 3 0 247 139 0.7000
- Team2 6 2 2 220 122 0.6000
- Team3 6 4 0 191 191 0.6000
- Team4 4 5 1 167 201 0.4000
- Team5 3 6 1 142 202 0.3000
- Team6 2 8 0 193 305 0.2000
- $result = mysql_query("
- SELECT team
- , COUNT(*) played
- , SUM(win) wins
- , SUM(loss) lost
- , SUM(win)/count(*) pctWon
- , SUM(draw) draws
- , SUM(SelfScore) ptsfor
- , SUM(OpponentScore) ptsagainst
- , SUM(SelfScore) - SUM(OpponentScore) goal_diff
- , SUM(3*win + draw) score
- FROM (
- SELECT team
- , SelfScore
- , OpponentScore
- , SelfScore > OpponentScore win
- , SelfScore < OpponentScore loss
- , SelfScore = OpponentScore draw
- FROM (
- SELECT HomeTeam team, HomeScore SelfScore, AwayScore OpponentScore
- FROM Game
- union all select AwayTeam, AwayScore, HomeScore
- FROM Game
- ) a
- ) b
- GROUP BY team
- ORDER BY wins DESC, draws DESC, lost ASC, goal_diff DESC;
- ");
- echo "<table border='1'>
- <tr>
- <th>Team</th>
- <th>W</th>
- <th>L</th>
- <th>T</th>
- <th>PF</th>
- <th>PA</th>
- <th>PCT</th>
- </tr>";
- while($row = mysql_fetch_assoc($result))
- {
- echo "<tr>";
- echo "<td>" . $row['team'] . "</td>";
- echo "<td>" . $row['wins'] . "</td>";
- echo "<td>" . $row['lost'] . "</td>";
- echo "<td>" . $row['draws'] . "</td>";
- echo "<td>" . $row['ptsfor'] . "</td>";
- echo "<td>" . $row['ptsagainst'] . "</td>";
- echo "<td>" . $row['pctWon'] . "</td>";
- echo "</tr>";
- }
- echo "</table>";
- ORDER BY wins DESC, draws DESC, lost ASC, goal_diff DESC;
- ORDER BY (wins*2 + draws) DESC, lost ASC, goal_diff DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement