@@ -0,0 +1,6 @@
|
||||
select
|
||||
game_competitiveness_tier,
|
||||
count(*) as games
|
||||
from main_marts.fct_game_results
|
||||
group by game_competitiveness_tier
|
||||
order by games desc
|
||||
@@ -0,0 +1,4 @@
|
||||
name: nba
|
||||
type: duckdb
|
||||
options:
|
||||
filename: dbt_nba.duckdb
|
||||
@@ -0,0 +1,8 @@
|
||||
select
|
||||
season_start_year || '-' || substr(cast(season_start_year + 1 as varchar), 3, 2) as season,
|
||||
round(100.0 * sum(case when is_overtime then 1 else 0 end) / count(*), 1) as ot_pct,
|
||||
round(100.0 * sum(case when point_differential <= 5 then 1 else 0 end) / count(*), 1) as clutch_pct,
|
||||
round(100.0 * sum(case when point_differential >= 20 then 1 else 0 end) / count(*), 1) as blowout_pct
|
||||
from main_intermediate.int_games_enriched
|
||||
group by season_start_year
|
||||
order by season_start_year
|
||||
@@ -0,0 +1,18 @@
|
||||
select
|
||||
g.game_date,
|
||||
g.home_points,
|
||||
g.visitor_points,
|
||||
g.total_points,
|
||||
g.point_differential,
|
||||
g.is_overtime,
|
||||
g.is_playoff,
|
||||
g.game_competitiveness_tier,
|
||||
g.is_home_team_winner,
|
||||
ht.team_abbr as home_team,
|
||||
vt.team_abbr as visitor_team,
|
||||
wt.team_abbr as winning_team
|
||||
from main_marts.fct_game_results g
|
||||
left join main_marts.dim_teams ht on g.home_team_key = ht.team_key
|
||||
left join main_marts.dim_teams vt on g.visitor_team_key = vt.team_key
|
||||
left join main_marts.dim_teams wt on g.winning_team_key = wt.team_key
|
||||
order by g.game_date desc
|
||||
@@ -0,0 +1,9 @@
|
||||
select
|
||||
s.season_display,
|
||||
count(*) as total_games,
|
||||
sum(case when g.is_home_team_winner then 1 else 0 end) as home_wins,
|
||||
round(100.0 * sum(case when g.is_home_team_winner then 1 else 0 end) / count(*), 1) as home_win_pct
|
||||
from main_marts.fct_game_results g
|
||||
left join main_marts.dim_seasons s on g.season_key = s.season_key
|
||||
group by s.season_display
|
||||
order by s.season_display
|
||||
@@ -0,0 +1,10 @@
|
||||
select
|
||||
season_start_year || '-' || substr(cast(season_start_year + 1 as varchar), 3, 2) as season,
|
||||
round(avg(matchup_pace), 1) as avg_pace,
|
||||
round(avg(total_points), 1) as avg_total_points,
|
||||
round(avg(home_effective_fg_pct + visitor_effective_fg_pct) / 2 * 100, 1) as avg_efg_pct,
|
||||
round(avg(point_differential), 1) as avg_margin,
|
||||
count(*) as games
|
||||
from main_intermediate.int_games_enriched
|
||||
group by season_start_year
|
||||
order by season_start_year
|
||||
@@ -0,0 +1,9 @@
|
||||
select
|
||||
shot_selection_style,
|
||||
count(*) as games,
|
||||
round(avg(case when game_result = 'W' then 1.0 else 0.0 end) * 100, 1) as win_pct,
|
||||
round(avg(offensive_rating), 1) as avg_off_rating
|
||||
from main_intermediate.int_team_performance
|
||||
where season_start_year = (select max(season_start_year) from main_intermediate.int_team_performance)
|
||||
group by shot_selection_style
|
||||
order by avg_off_rating desc
|
||||
@@ -0,0 +1,20 @@
|
||||
select
|
||||
player_name,
|
||||
team,
|
||||
count(*) as games,
|
||||
round(avg(points), 1) as ppg,
|
||||
round(avg(assists), 1) as apg,
|
||||
round(avg(total_rebounds), 1) as rpg,
|
||||
round(avg(box_plus_minus), 2) as avg_bpm,
|
||||
round(avg(usage_pct), 1) as avg_usage,
|
||||
round(avg(true_shooting_pct) * 100, 1) as ts_pct,
|
||||
round(avg(net_rating), 1) as avg_net_rating,
|
||||
sum(case when is_double_double then 1 else 0 end) as double_doubles,
|
||||
sum(case when is_triple_double then 1 else 0 end) as triple_doubles
|
||||
from main_intermediate.int_player_performance
|
||||
where season_start_year = (select max(season_start_year) from main_intermediate.int_player_performance)
|
||||
and minutes_played >= 20
|
||||
group by player_name, team
|
||||
having count(*) >= 20
|
||||
order by avg_bpm desc
|
||||
limit 30
|
||||
@@ -0,0 +1,11 @@
|
||||
select
|
||||
s.season_display,
|
||||
count(*) as total_games,
|
||||
sum(case when g.is_overtime then 1 else 0 end) as overtime_games,
|
||||
sum(case when g.is_playoff then 1 else 0 end) as playoff_games,
|
||||
round(avg(g.total_points), 1) as avg_total_points,
|
||||
round(avg(g.point_differential), 1) as avg_margin
|
||||
from main_marts.fct_game_results g
|
||||
left join main_marts.dim_seasons s on g.season_key = s.season_key
|
||||
group by s.season_display
|
||||
order by s.season_display desc
|
||||
@@ -0,0 +1,14 @@
|
||||
select
|
||||
team,
|
||||
count(*) as games,
|
||||
sum(case when game_result = 'W' then 1 else 0 end) as wins,
|
||||
round(100.0 * sum(case when game_result = 'W' then 1 else 0 end) / count(*), 1) as win_pct,
|
||||
round(avg(offensive_rating), 1) as avg_off_rating,
|
||||
round(avg(defensive_rating), 1) as avg_def_rating,
|
||||
round(avg(net_rating), 1) as avg_net_rating,
|
||||
round(avg(pace), 1) as avg_pace,
|
||||
round(avg(effective_fg_pct) * 100, 1) as avg_efg_pct
|
||||
from main_intermediate.int_team_performance
|
||||
where season_start_year = (select max(season_start_year) from main_intermediate.int_team_performance)
|
||||
group by team
|
||||
order by avg_net_rating desc
|
||||
@@ -0,0 +1,13 @@
|
||||
select
|
||||
p.player_name,
|
||||
count(*) as games_played,
|
||||
round(avg(ps.points), 1) as ppg,
|
||||
round(avg(ps.total_rebounds), 1) as rpg,
|
||||
round(avg(ps.assists), 1) as apg,
|
||||
round(avg(ps.true_shooting_pct) * 100, 1) as ts_pct
|
||||
from main_marts.fct_player_game_stats ps
|
||||
left join main_marts.dim_players p on ps.player_key = p.player_key
|
||||
group by p.player_name
|
||||
having count(*) >= 50
|
||||
order by ppg desc
|
||||
limit 20
|
||||
@@ -0,0 +1,13 @@
|
||||
select
|
||||
player_name,
|
||||
team,
|
||||
count(*) as games,
|
||||
round(avg(usage_pct), 1) as usage,
|
||||
round(avg(true_shooting_pct) * 100, 1) as efficiency,
|
||||
round(avg(points), 1) as ppg
|
||||
from main_intermediate.int_player_performance
|
||||
where season_start_year = (select max(season_start_year) from main_intermediate.int_player_performance)
|
||||
and minutes_played >= 20
|
||||
group by player_name, team
|
||||
having count(*) >= 20
|
||||
order by usage desc
|
||||
Reference in New Issue
Block a user