Invalid query : select ttTecmoOrder, ttName, ttCity, sum(gsAttempts) as passatts, sum(gsPassYards) as PassYards, sum(gsPassTDs) as passtds, sum(gsRushTDs) as rushtds, sum(gsRushes) as rushes, sum(gsRushYards) as RushYards, sum(gsPassYards)+sum(gsRushYards) as TotalYards, sum(gsRushYards)/COUNT(DISTINCT(gsgUID)) as rushydsavg, sum(gsPassYards)/COUNT(DISTINCT(gsgUID)) as passydsavg, ((sum(gsPassYards)+sum(gsRushYards))/COUNT(DISTINCT(gsgUID))) as totalavg , 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 = 2003 AND tttID = gsTeam AND psUID = gsSeason AND gsTeam = tttID AND psUID = ttsUID AND gsWeek <= 16 group by tttID order by desc, totalavg desc