ok so there's two tables. One called teams, (contains the teams in a league)
The other table is called schedule which has four columns
hometeam, awayteam, homescore, awayscore (and a few others like gamedate, gametime, and id)

The objective is to calculate each team's wins, losses, gb (games behind) pct (winning percentage) pf (total points scored) pa (total points scored against the team)

I got the calculations for wins, losses, pf and pa,

What I am not sure how to do is get mysql to calcuate the pct (w/(w+l)) and the games behind
max((w-l)/2) + (w-l)/2.

The mysql version being used is 4.0 both on my computer and my hosting provider's.

My other question is how scalable is the below query. For example if the program had to calculate 82 games per team with 30 teams in the league?

Code:
SELECT team, 
SUM(CASE WHEN hometeam = standings.team THEN homescore WHEN awayteam = standings.team THEN awayscore END) AS pf, 
SUM(CASE WHEN awayteam = standings.team THEN homescore WHEN hometeam = standings.team THEN awayscore END) AS pa, 
count(CASE WHEN hometeam = standings.team AND homescore > awayscore THEN hometeam WHEN awayteam = standings.team AND awayscore > homescore THEN awayteam END) AS w, 
count(CASE WHEN hometeam = standings.team AND homescore < awayscore THEN hometeam WHEN awayteam = standings.team AND awayscore < homescore THEN awayteam END) AS l 
FROM schedule, standings GROUP BY standings.team ORDER BY w DESC,l ASC