Invalid query : select pID, first, last, sum(gsAttempts) as passatts, sum(gsComps) as passcomps, sum(gsComps)/sum(gsAttempts)*100 as compPerc, sum(gsPassYards) as passyds, sum(gsPassTDs) as passtds, sum(gsINTs) as passints, ((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 , tID, city, tname, dod from tecmoplayer, game_stats, tecmoteam where pID = gspUID AND tID = gsTeam AND gsSeason = AND gslUID = 1 AND gPlayoff = 0 AND pos = 0 group by gspUID, gsSeason order by (sum(gsAttempts) > 4*16) desc, nfl_rating desc