Demetrius Murray 372f14316b complete | 6 years ago | |
---|---|---|
.idea | 6 years ago | |
Part1 | 6 years ago | |
Part2 | 6 years ago | |
Part3 | 6 years ago | |
Part4 | 6 years ago | |
README.md | 6 years ago | |
pokemon_sql.zip | 6 years ago |
Directions:
From here you should have all the pokemon data in your mysql schema. Feel free to explore the data and perform a few select statements to see what the data looks like.
Directions: Write a sql query or sql queries that can answer the following questions
What are all the types of pokemon that a pokemon can have?
SELECT COUNT(id) FROM pokemon.types;
What is the name of the pokemon with id 45?
SELECT name FROM pokemon.pokemons WHERE id = 45;
How many pokemon are there?
SELECT COUNT(id) FROM pokemon.pokemons;
How many types are there?
How many pokemon have a secondary type?
SELECT COUNT(id) FROM pokemon.pokemons WHERE secondary_type IS NOT NULL;
Directions: Write a sql query or sql queries that can answer the following questions
What is each pokemon's primary type?
SELECT pokemon.pokemons.name, pokemon.types.name
FROM pokemon.pokemons
JOIN pokemon.types ON pokemons.primary_type = types.id;
What is Rufflet's secondary type?
SELECT pokemons.name, pokemons.secondary_type, types.name
FROM pokemon.pokemons
JOIN pokemon.types
ON pokemons.secondary_type = types.id
WHERE pokemons.name = "Rufflet";
What are the names of the pokemon that belong to the trainer with trainerID 303?
SELECT pokemons.name FROM pokemon.pokemons
JOIN pokemon.pokemon_trainer
ON pokemons.id = pokemon_trainer.pokemon_id
WHERE pokemon_trainer.trainerID = 303;
How many pokemon have a secondary type Poison
SELECT pokemon.types.name, COUNT(pokemon.pokemons.name) AS "Count - Type Poison"
FROM pokemon.pokemons
JOIN pokemon.types
ON pokemon.pokemons.secondary_type = pokemon.types.id
WHERE pokemon.types.name = "Poison";
What are all the primary types and how many pokemon have that type?
SELECT pokemon.types.name, COUNT(pokemon.pokemons.name) AS "Count"
FROM pokemon.pokemons
JOIN pokemon.types
ON pokemons.primary_type = types.id
GROUP BY pokemon.types.id;
How many pokemon at level 100 does each trainer with at least one level 100 pokemone have? (Hint: your query should not display a trainer
SELECT COUNT(pokemon_trainer.pokemon_id)
FROM pokemon.pokemon_trainer
WHERE pokemon.pokemon_trainer.pokelevel = 100;
Not sure how to answer the "each" part of the question without showing trainers. So below is an alternative response that shows "each" trainer by trainerID.
SELECT COUNT(pokemon_trainer.pokemon_id)
FROM pokemon.pokemon_trainer
WHERE pokemon.pokemon_trainer.pokelevel = 100
GROUP BY pokemon_trainer.trainerID;
How many pokemon only belong to one trainer and no other?
the answer is 0.
SELECT COUNT(pokemon.pokemon_trainer.pokemon_id) FROM pokemon.pokemon_trainer HAVING COUNT(pokemon_trainer.trainerID) = 1;
Directions: Write a query that returns the following collumns:
Pokemon Name | Trainer Name | Level | Primary Type | Secondary Type |
---|---|---|---|---|
Pokemon's name | Trainer's name | Current Level | Primary Type Name | Secondary Type Name |
Sort the data by finding out which trainer has the strongest pokemon so that this will act as a ranking of strongest to weakest trainer. You may interpret strongest in whatever way you want, but you will have to explain your decision.
To turn in this assignment, create files for each part with at least one query for each question answered. Above each query include a comment with the question you were answering. Example:
# How many characters are in the string 'Hello World!'
SELECT CHAR_LENGTH('Hello World!') AS length_of_hello_world
For Part 4 specifically also leave a comment explaining how your query is deciding who the strongest trainer is
Once all of that is done, submit a pull request