Forum Moderators: coopster
statid ¦ gameid ¦ playerid ¦ teamname ¦ blah blah blah
I use group by to pull all the stats for each playerid. But what I find is that when a player changes teams it pulls the first teamname from the table rather than the last. Will MAX(teamname) work to show the final team or will that just alphabetize it?
$query_goalies = "SELECT goalie_stats.playerid, goalie_stats.teamid, firstname, lastname, teamname,
SUM(IF(time='0',1,0)) AS gp,
SUM(IF(time='0',mins,0)) AS mins,
SUM(IF(result='win' AND time='0',1,0)) AS wins,
SUM(IF(result='loss' AND time='0',1,0)) AS losses,
SUM(IF(result='tie' AND time='0',1,0)) AS ties,
SUM(IF(time='0',ga,0)) AS ga,
SUM(IF(ga='0' AND time='0' AND result!='NULL',1,0)) AS so,
SUM(IF(time='0',ga,0))/SUM(IF(time='0',mins,0))*40 AS gaa,
SUM(IF(time='1',1,0)) AS pogp,
SUM(IF(time='1',mins,0)) AS pomins,
SUM(IF(result='win' AND time='1',1,0)) AS powins,
SUM(IF(result='loss' AND time='1',1,0)) AS polosses,
SUM(IF(result='tie' AND time='1',1,0)) AS poties,
SUM(IF(time='1',ga,0)) AS poga,
SUM(IF(ga='0' AND time='1' AND result!='NULL',1,0)) AS poso,
SUM(IF(time='1',ga,0))/SUM(IF(time='1',mins,0))*40 AS pogaa
FROM players, goalie_stats, teams
WHERE teams.teamid = goalie_stats.teamid AND players.playerid = goalie_stats.playerid AND season = 2006
GROUP BY goalie_stats.playerid
ORDER BY gaa ASC, mins DESC";
I tried to add LAST() in but I get an error:
[webmasterworld.com...]