Invalid query dude : select pUID, first, last, ttAbrev, ttTecmoOrder, sum(gsAttempts) as Attempts, sum(gsComps) as Comps, sum(gsComps)/sum(gsAttempts)*100 as compPerc, sum(gsPassYards) as PassYards, sum(gsPassTDs) as TDs, sum(gsINTs) as INTs, sum(gsPassYards)/sum(gsAttempts) as Avg, ((GREATEST(0, LEAST(2.375,((((SUM(gsComps) / SUM(gsAttempts)) * 100) - 30) * .05))) + GREATEST(0, LEAST(2.375,(((SUM(gsPassYards) / SUM(gsAttempts)) - 3) * .25))) + LEAST(2.375, ((SUM(gsPassTDs) / SUM(gsAttempts)) *20)) + GREATEST(0, (2.375 -((SUM(gsINTs) / SUM(gsAttempts)) * 25))))*50/3) AS nfl_rating, CASE WHEN (pPC>=63 OR (pPC=56 AND pPS>=69 AND pMS>=13) OR (pPC=56 AND pMS>=25)) THEN 'A' WHEN (pPC=50 OR (pPC=56 AND pPS<=63 AND pMS<=19) OR (pPC=44 AND pPS>=69 AND pMS>=13) OR (pPC=44 AND pMS>=25)) THEN 'B' ELSE 'C' END AS Grade , 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 AND pPos = 0 group by gspUID, gsTeam having sum(gsAttempts) > 0 order by desc, nfl_rating desc, compPerc desc