|
| 1 | +with |
| 2 | + |
| 3 | +fct_games_played as ( |
| 4 | + select * from {{ ref('fct_games_played') }} |
| 5 | +), |
| 6 | + |
| 7 | +dim_games as ( |
| 8 | + select * from {{ ref('dim_games') }} |
| 9 | +), |
| 10 | + |
| 11 | +dim_teams as ( |
| 12 | + select * from {{ ref('dim_teams') }} |
| 13 | +), |
| 14 | + |
| 15 | +dim_calendar_dates as ( |
| 16 | + select * from {{ ref('dim_calendar_dates') }} |
| 17 | +), |
| 18 | + |
| 19 | +final as ( |
| 20 | + |
| 21 | + select |
| 22 | + dim_games.game_id, |
| 23 | + dim_games.game_date, |
| 24 | + dim_calendar_dates.short_weekday_name, |
| 25 | + dim_calendar_dates.short_month_name, |
| 26 | + dim_calendar_dates.short_month_year, |
| 27 | + dim_games.status_long, |
| 28 | + |
| 29 | + home_teams.team_name as home_team_name, |
| 30 | + home_teams.head_coach as home_team_head_coach, |
| 31 | + home_teams.general_manager as home_team_general_manager, |
| 32 | + home_teams.division as home_team_division, |
| 33 | + home_teams.conference as home_team_conference, |
| 34 | + |
| 35 | + away_teams.team_name as away_team_name, |
| 36 | + away_teams.head_coach as away_team_head_coach, |
| 37 | + away_teams.general_manager as away_team_general_manager, |
| 38 | + away_teams.division as away_team_division, |
| 39 | + away_teams.conference as away_team_conference, |
| 40 | + |
| 41 | + fct_games_played.home_team_score_total, |
| 42 | + fct_games_played.home_team_score_quarter_1, |
| 43 | + fct_games_played.home_team_score_quarter_2, |
| 44 | + fct_games_played.home_team_score_quarter_3, |
| 45 | + fct_games_played.home_team_score_quarter_4, |
| 46 | + fct_games_played.home_team_score_overtime, |
| 47 | + fct_games_played.average_home_pts_per_quarter, |
| 48 | + |
| 49 | + fct_games_played.away_team_score_total, |
| 50 | + fct_games_played.away_team_score_quarter_1, |
| 51 | + fct_games_played.away_team_score_quarter_2, |
| 52 | + fct_games_played.away_team_score_quarter_3, |
| 53 | + fct_games_played.away_team_score_quarter_4, |
| 54 | + fct_games_played.away_team_score_overtime, |
| 55 | + fct_games_played.average_away_pts_per_quarter, |
| 56 | + |
| 57 | + fct_games_played.point_differential, |
| 58 | + fct_games_played.home_team_win_count, |
| 59 | + fct_games_played.away_team_win_count |
| 60 | + |
| 61 | + from fct_games_played |
| 62 | + |
| 63 | + left join dim_games |
| 64 | + on fct_games_played.game_sk = dim_games.game_sk |
| 65 | + |
| 66 | + left join dim_teams as home_teams |
| 67 | + on fct_games_played.home_team_sk = home_teams.team_sk |
| 68 | + |
| 69 | + left join dim_teams as away_teams |
| 70 | + on fct_games_played.away_team_sk = away_teams.team_sk |
| 71 | + |
| 72 | + left join dim_calendar_dates |
| 73 | + on fct_games_played.game_date_sk = dim_calendar_dates.calendar_date_sk |
| 74 | + |
| 75 | + where dim_games.status_long != 'Not Started' |
| 76 | + |
| 77 | +) |
| 78 | + |
| 79 | +select * from final order by game_date desc -- For a cleaner view |
0 commit comments