nba_active_players_countnba_home_away_top_points_by_teamnba_home_away_wins_by_teamnba_player_birth_countries_allnba_player_experience_distribution_by_teamnba_player_experience_distribution_by_team_detailnba_player_nationalities_in_teamnba_rookie_players_countnba_team_arena_capacitiesnba_team_arena_capacitynba_team_average_points_allowednba_team_average_points_per_gamenba_team_foundation_yearnba_team_inputnba_team_overviewnba_team_performance_over_timenba_team_total_winsnba_teams_countnba_top_10_experienced_players_in_teamnba_top_10_team_by_total_winsnba_top_teams_by_points_per_game
Query: nba_top_teams_by_points_per_game
Usage
powerpipe query nba.query.nba_top_teams_by_points_per_game
SQL
with total_points as ( select team_id_home as team_id, sum(pts_home) as points from game group by team_id_home union all select team_id_away, sum(pts_away) from game group by team_id_away),game_counts as ( select team_id, COUNT(*) as games_played from ( select team_id_home as team_id from game union all select team_id_away from game ) group by team_id),avg_points as ( select tp.team_id, sum(tp.points) / gc.games_played as avg_points_per_game from total_points tp join game_counts gc on tp.team_id = gc.team_id group by tp.team_id order by avg_points_per_game desc)select t.full_name, ap.avg_points_per_gamefrom avg_points apjoin team t on ap.team_id = t.idorder by avg_points_per_game desc;
Dashboards
The query is used in the dashboards: