Sports Statistics
I am not sure if this is the correct place to put this, so please let me know if it should be somewhere else.
I am new to MySQL. I am trying to implement a sports statistics page for a website. I have figured out how to get totals and averages for a single game for each player, but I want to know how to display totals and averages over several games for each player.
Example: I can "SELECT * FROM stats2 WHERE game_id=1" to display all the players' stats for game 1. It will list each player in a row with their stats for that game, because I specified game #1. No problem.
The question is how do I display each player in a row with their cumulative stats (totals & averages) after 2 games? 3games? 10 games? I have 3 games worth of data in the table at this point, but cannot display the stats correctly. What I have gotten so far is a table with each player's stats for each game.
Example output:
PLAYER - FGM - FGA - FTM - FTA - TRB
John Doe - 2 - 4 - 1 - 3 - 5
John Doe - 0 - 2 - 2 - 3 - 3
John Doe - 3 - 5 - 1 - 1 - 2
Dave Smith - 2 - 3 - 1 - 2 - 2
Dave Smith - 1 - 3 - 2 - 3 - 1
Dave Smith - 3 - 4 - 1 - 2 - 1
and so on for each player.
I would like to have each player listed only once, with their totals and averages based on number of games played.
This is the biggest trouble I have been having trying to learn MySQL. If anyone can help me I would greatly appreciate it! I can provide more detail if needed.
Edited 3 time(s). Last edit at 08/18/2009 10:42PM by Rod Trexler.
Subject
Written By
Posted
Sports Statistics
August 18, 2009 10:25PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.