turbot/nba

Query: nba_home_away_top_points_by_team

Usage

powerpipe query nba.query.nba_home_away_top_points_by_team

SQL

with home_points as (
select
team_id_home as team_id,
sum(pts_home) as home_points
from
game
group by
team_id_home
),
away_points as (
select
team_id_away as team_id,
sum(pts_away) as away_points
from
game
group by
team_id_away
)
select
t.full_name,
h.home_points,
a.away_points
from
home_points h
join away_points a on h.team_id = a.team_id
left join team t on h.team_id = t.id
order by
a.away_points, h.home_points desc;

Dashboards

The query is used in the dashboards: