drelefun
Technical User
- Apr 16, 2008
- 15
Hi
I have two tables which i am trying to get data from. The two tables are
AFLPlayerStats( aflgame_id(pk), team_id(pk), player_id(pk), kicks, handballs. goals, behinds, hitouts, tackles)
and
AFLScore(aflgame_id, team_id(pk), quarter(pk), goals, behinds)
What I want to do is SUM(AFLPlayerStats.kicks + AFLPlayerStats.handballs) / SUM(AFLPlayerStats.goals + AFLPlayerStats.behinds) AS 'Possesions Per Score'
I thought it was a basic two table join
SELECT AFLScore.team_id, SUM(AFLPlayerStats.kicks + AFLPlayerStats.handballs) / SUM(AFLPlayerStats.goals + AFLPlayerStats.behinds) AS 'Possesions Per Score'
FROM AFLPlayerStats INNER JOIN
AFLScore ON AFLPlayerStats.aflgame_id = AFLScore.aflgame_id AND AFLPlayerStats.team_id = AFLScore.team_id
GROUP BY AFLScore.team_id
but i'm assuming there is something i need to do with the quarter and player_id fields. can anyone help?
thanks
ben
I have two tables which i am trying to get data from. The two tables are
AFLPlayerStats( aflgame_id(pk), team_id(pk), player_id(pk), kicks, handballs. goals, behinds, hitouts, tackles)
and
AFLScore(aflgame_id, team_id(pk), quarter(pk), goals, behinds)
What I want to do is SUM(AFLPlayerStats.kicks + AFLPlayerStats.handballs) / SUM(AFLPlayerStats.goals + AFLPlayerStats.behinds) AS 'Possesions Per Score'
I thought it was a basic two table join
SELECT AFLScore.team_id, SUM(AFLPlayerStats.kicks + AFLPlayerStats.handballs) / SUM(AFLPlayerStats.goals + AFLPlayerStats.behinds) AS 'Possesions Per Score'
FROM AFLPlayerStats INNER JOIN
AFLScore ON AFLPlayerStats.aflgame_id = AFLScore.aflgame_id AND AFLPlayerStats.team_id = AFLScore.team_id
GROUP BY AFLScore.team_id
but i'm assuming there is something i need to do with the quarter and player_id fields. can anyone help?
thanks
ben