Invalid query : select ttTecmoOrder, ttName, ttCity, sum(gsINTs) as ints, sum(gsINTs)/COUNT(DISTINCT(gsgUID)) as avgints, sum(gsInj)/3 as inj, ttPointsFor as pts, ttPointsFor/COUNT(DISTINCT(gsgUID)) as avgpts , 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, avgpts desc