Sangsom Sangsom - 1 year ago 376
SQL Question

Sean Lahman database sample queries

Is there any place where can I find sample queries (SELECT, UPDATE, DELETE) for Sean Lahman database? I wanna see what can be done with this database..

Answer Source

I use to ship the database with sample queries. Maybe I should revisit that idea. Here are a few to get you started.

A simple one to show all of the players named "Sean:"

SELECT nameLast, nameFirst, debut
FROM Master
WHERE (nameFirst="Sean")
ORDER BY nameLast;

Here's one to show a list of players with 50 HRs in a season:

SELECT Master.nameLast, Master.nameFirst, Batting.HR, Batting.yearID
FROM Batting INNER JOIN Master ON Batting.playerID = Master.playerID
WHERE (((Batting.HR)>=50))

Here's one to show the all-time leaders in strikeouts:

SELECT Master.nameLast, Master.nameFirst, Sum(Pitching.SO) AS SumOfSO
FROM Pitching INNER JOIN Master ON Pitching.playerID = Master.playerID
GROUP BY Pitching.playerID, Master.nameLast, Master.nameFirst
ORDER BY Master.nameLast;

There are several websites with tutorials on using the database that include sample queries. See:

You can find more by googling 'sql lahman'

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download