SQL Practice - Baseball Players


  1. Download the file Baseball-Player.sql. into a top-level directory named exactly Baseball-1.
    Download the ActivityJournal.txt and fill it in for each query. The file contains SQL statements to create and populate a table of baseball players:

    CREATE TABLE Player(
      name TEXT,
      position INTEGER,
      number INTEGER,
      team TEXT,
      age INTEGER
    ) ;

  2. The players are all those on the active rosters of teams in the American League East as of 4/28/2015.

  3. Create a file Query.sql with SELECT statements that retrieve the information requested below. To run your queries against the provided database, do the following:

    $ sqlite3
    SQLite version 3.7.9 2011-11-01 00:52:41
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite> .read Baseball-Player.sql
    sqlite> .read Query.sql
    You may, of course, try out your queries from the command line while in sqlite, but only what is in Query.sql will be graded.
  4. We will grade each query in Query.sql for correctness (5 points each). The desired output is in QueryOutput.txt.


  1. Find all the information on all the catchers (position 2) in the database.

  2. Find the name and age of all pitchers (position 1) on the Rays.

  3. Find the name, number, and team of all outfielders (positions 7 through 9) who are 25 years old or younger.

  4. Find the name and number of all infielders (positions 3 through 6) on the Red Sox.

  5. Find the name, number, and team of all pitchers who are over 30 years old.

Submission and Grading