First of all, this looks like bad table design. A table with similar columns most probably should be split in at least two tables.
Second, you don't tell where your problem is. To count non-zero column values in a stored procedure or function this function will have to contain an expression like
if(game1 is not null, 1, 0)
+ if(game2 is not null, 1, 0)
...
+ if(game9 is not null, 1, 0)
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254
Your design is definitively flawed as one information - the outcome of a game - is stored in two locations: with each team separately.
I'd propose a structure like:
teams (team_id, team_name)
games (game_id, team_1, team_2, game_result)
With this structure it is much easier to count games, to avoid duplicates or to calculate averages.
smantscheff
Nearly a Posting Virtuoso
1,233 posts since Oct 2010
Reputation Points: 300
Solved Threads: 254