Created
January 6, 2015 23:07
-
-
Save rabidpraxis/741d22330aac34c86433 to your computer and use it in GitHub Desktop.
Team average
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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