You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.1 KiB

ga

NFL


Title: NFL
Type: Homework
Modified by: Karolin Rafalski, Thom Page
Competencies: Basic SQL


Schema and seed

You are provided with a schema file schema.sql and two seed files players.sql, teams.sql that are also in the nfl_seed_data folder. Create a new database called nfl and use the schema and seed file to populate your database.


🔴 "Commit: NFL db seeded"

Record your answers to Step 3 in a file called nfl.sql.

Challenge: Complete each part with a single SQL expression. That is possible, but for some queries, it will involve learning how to use compound SQL expressions.

Queries

Some queries may require more than one command (i.e. you may need to get information about a team before you can complete a query for players). Test each command in PSQL to make sure it is correct.

  1. List the names of all NFL teams
  2. List the stadium name and head coach of all NFC teams
  3. List the head coaches of the AFC South
  4. The total number of players in the NFL

🔴 "Commit: NFL queries 1"
  1. The team names and head coaches of the NFC North and AFC East
  2. The 50 players with the highest salaries
  3. The average salary of all NFL players
  4. The names and positions of players with a salary above 10_000_000

🔴 "Commit: NFL queries 2"
  1. The player with the highest salary in the NFL
  2. The name and position of the first 100 players with the lowest salaries
  3. The average salary for a DE in the nfl

🔴 "Commit: NFL queries 3"

Hungry For More

For these you will need to query two tables at the same time. In order to do some parts you will need to research commands using dot notation that we did not cover in class.

EXAMPLE

The names of all the players on the Buffalo Bills

SELECT players.name, teams.name
FROM players, teams
WHERE players.team_id=teams.id AND teams.name LIKE 'Buffalo Bills';
  1. The total salary of all players on the New York Giants
  2. The player with the lowest salary on the Green Bay Packers

🔴 "Commit: NFL - HFM"