Invalid query dude : select ttTecmoOrder, ttName, ttCity, (sum(qtr1h)+sum(qtr1a))/COUNT(DISTINCT(gsgUID)) as qtr1_s, (sum(qtr2h)+sum(qtr2a))/COUNT(DISTINCT(gsgUID)) as qtr2_s, (sum(qtr3h)+sum(qtr3a))/COUNT(DISTINCT(gsgUID)) as qtr3_s, (sum(qtr4h)+sum(qtr4a))/COUNT(DISTINCT(gsgUID)) as qtr4_s, (sum(oth)+sum(ota))/COUNT(DISTINCT(gsgUID)) as ot_s, (sum(fdh)+sum(fda))/COUNT(DISTINCT(gsgUID)) as fd, sum(fumh)+sum(fuma) as fum, sum(fumhl)+sum(fumal) as fuml, (sum(fumh)+sum(fuma))/COUNT(DISTINCT(gsgUID)) as fum_g, (sum(fumhl)+sum(fumal))/COUNT(DISTINCT(gsgUID)) as fuml_g, (sum(toph)+sum(topa))/COUNT(DISTINCT(gsgUID)) as top, tttID, pNumber, COUNT(DISTINCT(gsgUID)) as gp, pInjured from player_atts, tecmoplayer, standings, game_stats where pUID = pID AND pttUID = ttTecmoOrder AND pUID = gspUID AND plUID = 1 AND gslUID = plUID AND ttlUID = gslUID AND gsSeason = 2010 AND tttID = gsTeam AND psUID = gsSeason AND gsTeam = tttID AND psUID = ttsUID AND gsWeek <= 20 group by tttID order by desc, fum desc