What is the average attendance?
select avg(attendance) from home_game
What is the average attendance of each team in 2013?
select t2.team_id, avg(t1.attendance) from home_game as t1 join team as t2 on t1.team_id = t2.team_id where t1.year = 2013 group by t1.team_id
How about in 2014?
select t2.team_id, avg(t1.attendance) from home_game as t1 join team as t2 on t1.team_id = t2.team_id where t1.year = 2014 group by t1.team_id
Please list the id and rank of the team that had the largest average attendance in that year.
select t2.team_id, t2.rank from home_game as t1 join team as t2 on t1.team_id = t2.team_id where t1.year = 2014 group by t1.team_id order by avg(t1.attendance) desc limit 1;