More Baseball Statistics

May 30, 2004 | Baseball | By: Mark VandeWettering

Baseball-DataBank.org has statistics similar (identical?) to those from baseball1.com but has conveniently placed them in the form of a 33 megabyte file that you can import directly into MySQL. With it, you can formulate pretty simple queries in SQL and learn, for instance, the top 10 players of all time in ABs..

mysql> select sum(Batting.AB), concat(Master.nameFirst, ' ', Master.nameLast) 
from Batting, Master where Master.playerID = Batting.playerID 
group by Master.playerID order by 1 desc limit 10 ;
+-----------------+------------------------------------------------+
| sum(Batting.AB) | concat(Master.nameFirst, ' ', Master.nameLast) |
+-----------------+------------------------------------------------+
|           14053 | Pete Rose                                      |
|           12364 | Hank Aaron                                     |
|           11988 | Carl Yastrzemski                               |
|           11551 | Cal Ripken Jr.                                 |
|           11434 | Ty Cobb                                        |
|           11336 | Eddie Murray                                   |
|           11008 | Robin Yount                                    |
|           11003 | Dave Winfield                                  |
|           10972 | Stan Musial                                    |
|           10961 | Rickey Henderson                               |
+-----------------+------------------------------------------------+
10 rows in set (3.73 sec)