I have a set of Hockey stats imported into a data frame in R. I'm having trouble finding the right queries for the set of data I want.
All records are kept in 1 table called skaters
Name Team Opp G
AAAAA PHI BOS 2
BBBBB NYR OTT 7
AAAAA PHI BOS 9
DDDDD BOS PHI 3
EEEEE BOS PHI 1
FFFFF PHI BOS 2
GGGGG OTT NYR 3
I'd like to find a way to take a sum of G per team. Thoughts were to you use a query like
SELECT DISTINCT(Team), SUM(G) FROM skaters
but this didn't give me what I was anticipating.
Then I found the GROUP BY function, which found the correct data. Then I wanted to up the ante once more.
I want to perform a query that will perform the sum I was looking for, but for both the home and away teams and compare them.