2.1 KiB
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.
- List the names of all NFL teams
- List the stadium name and head coach of all NFC teams
- List the head coaches of the AFC South
- The total number of players in the NFL
🔴 "Commit: NFL queries 1"
- The team names and head coaches of the NFC North and AFC East
- The 50 players with the highest salaries
- The average salary of all NFL players
- The names and positions of players with a salary above 10_000_000
🔴 "Commit: NFL queries 2"
- The player with the highest salary in the NFL
- The name and position of the first 100 players with the lowest salaries
- 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';
- The total salary of all players on the New York Giants
- The player with the lowest salary on the Green Bay Packers
🔴 "Commit: NFL - HFM"
