Skip to content

Instantly share code, notes, and snippets.

@rabidpraxis
Created January 6, 2015 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rabidpraxis/741d22330aac34c86433 to your computer and use it in GitHub Desktop.
Save rabidpraxis/741d22330aac34c86433 to your computer and use it in GitHub Desktop.
Team average
WITH teams AS (
SELECT
away_team as team,
away_score as score
FROM game
WHERE game.season_year = 2014
AND game.season_type = 'Regular'
UNION
SELECT
home_team as team,
home_score as score
FROM game
WHERE game.season_year = 2014
AND game.season_type = 'Regular'
)
SELECT
team,
avg(score)
FROM teams
GROUP BY team
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment