Sabermetrics

In this article I introduce you to the world of Sabermetrics. Sabermetrics is the analysis of baseball statistics to measure player performance, in game probabilities and much more.

With Sabermetrics you’ll be able to do most anything from decide who was the greatest hitter of all time to analyze the probability that your team will win.

But, to get started with Sabermetrics, you need to first get your tools being MySQL and a Baseball Stat Database. Both are free! More info follows the video below.

If you like videos like this tell google [googleplusone], or share it

More on Sabermetrics

I plan on covering many more Sabermetric formulas, but you can find mostly everyone of them in The Bill James Historical Baseball Abstract. He is credited with first publishing many of the formulas we will explore.

Code from the Video

```LOAD SQL DUMP FILE
(Shawn Lahman's Free BaseBall Database)

SHOW DATABASES

show databases;

USE DATABASE

use lahman591;

HOW TO KILL A QUERY

1. Open a new Terminal
2. SHOW PROCESSLIST;
3. KILL QUERY id;

SHOW TABLES AND DESCRIBE THEM

SHOW TABLES;
DESCRIBE Batting; # Using Table Named Batting

TEAM NAME AND SALARY

describe salaries; # Show salaries Table

PROOF SABERMETRICS WORKED 2002 ATHLETICS 103 WINS

SELECT s.yearID, s.teamID,
SUM(s.salary) AS SALARY,
t.W AS WINS,
SALARY/t.W AS CPW
FROM salaries s, teams t
WHERE s.yearID = 2002 AND s.teamID = t.teamID
AND s.yearID = t.yearID
GROUP BY s.teamID
ORDER BY SALARY DESC;```

13 Responses to “Sabermetrics”

1. mr.roshik says:

Thanks for new lesson.

You’re welcome. I wanted to make the Java Tutorial a little more interesting

2. Nathan Martinez says:

I need help I can’t seem to get it to run right it always sends the following error message:

• Derek Banas says:

Do this to make sure you have MySQL in your terminal program sudo find / -name mysql

You’ll see a bunch of lines if you have MySQL installed. Copy and past the one that is in the bin directory.

To make everything executable by just typing mysql, check out this nice tutorial http://495west.com/post/4895753657/bash-mysql-command-not-found

• Anonymous says:

Now when i did that it makes me enter a password
what is this ?

• Nathan Martinez says:

When i do that it makes me enter a password

• Derek Banas says:

You need a password and userid to use the database

• Nathan Martinez says:

Where do i change this

• Nathan Martinez says:

what do i do if i don’t know the password

3. Nathan Martinez says:

Where do i change this

4. sham says:

hello derek,
if i do not give ‘group by s.teamID’ clause for query, i get single record for teamID ANA why?
i want to understand this.

Select s.yearID, s.teamID, sum(s.salary) as salary, t.w as wins, salary/t.w as cpw from salaries s ,teams t where s.yearID = 2002 and s.teamID = t.teamID and s.yearID = t.yearID;

5. sham says:

hello derek,
If i remove
Group by clause
In any of your sql query,
I get only one entry instead of multiple entries.
Why?