Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save dnasca/b0eb904958affa00a519 to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/b0eb904958affa00a519 to your computer and use it in GitHub Desktop.
This query will return some offensive stats on the 1995 ATL Braves players with >= 300 AB's during that season, sorted by AB's.
SELECT
b.playerID,
CONCAT(m.nameFirst, ' ', m.nameLast) AS NAME,
AB,
H,
2B,
3B,
HR,
R,
RBI,
SB,
ROUND(BB / (AB + BB + HBP + COALESCE(SF, 0)) * 100, 2) AS BBPERC, #walks percentage
ROUND(SO / (AB + BB + HBP + COALESCE(SF, 0)) * 100, 2) AS SOPERC, #strikeout percentage
ROUND((H / AB), 3) AS AVG,
(H + BB + HBP) / (AB + BB + HBP + SF) AS OBP,
(H + 2B + 2 * 3B + 3 * HR) / AB AS SLG
FROM
Batting b,
Master m
WHERE
b.playerID = m.playerID
AND yearID = 1995
AND teamID = 'ATL'
GROUP BY b.playerID
HAVING AB >= 300
ORDER BY AB DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment