Sql question

I have two models of matches and teams that are in habtm relations.
now now to render all the teams with the number of other teams that they
have match with? Also I tried to run find_by_sql but don’t know how to
add :include with it. Any help?