Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.DS_Store
13 changes: 13 additions & 0 deletions part1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Select count(*) from pokemon_trainer;

Select * from pokemon_trainer limit 10;

Select * from types;

Select count(*) from pokemons;

Select * from pokemons limit 10;

Select count(*) from trainers;

Select * from pokemons limit 10;
14 changes: 14 additions & 0 deletions part2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#What are all the types of pokemon that a pokemon can have?
select name as pokemon_type from types;

#What is the name of the pokemon with id 45?
Select name from pokemons where id = 45;

#How many pokemon are there?
Select count(*) as nr_of_pokemon from pokemons;

#How many types are there?
Select count(*) as nr_of_types from types;

#How many pokemon have a secondary type?
Select count(*), name from pokemons where secondary_type is not null group by id;
20 changes: 20 additions & 0 deletions part3.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#What is each pokemon's primary type?
Select p.name as pokemon_name, t.name as primary_type from types as t inner join pokemons as p where p.primary_type = t.id order by p.name;

#What is Rufflet's secondary type?
Select p.name as pokemon_name, t.name as secondary_type from pokemons as p inner join types as t where p.secondary_type = t.id and p.name = 'Rufflet';

#What are the names of the pokemon that belong to the trainer with trainerID 303?
Select p.name as pokemon_name from pokemons as p join pokemon_trainer as pt on p.id = pt.pokemon_id where pt.trainerId = 303;

#How many pokemon have a secondary type Poison
Select count(*) as nr_pokemons, t.name as type from pokemons as p join types as t on p.secondary_type = t.id where t.name = 'Poison';

#What are all the primary types and how many pokemon have that type?
Select count(p.id) as pokemon_count, t.name as type from pokemons as p join types as t on p.primary_type = t.id group by p.primary_type;

#How many pokemon at level 100 does each trainer with at least one level 100 pokemon have? (Hint: your query should not display a trainer
Select count(trainerid) as nr_pokemons, pokelevel as level from pokemon_trainer where pokelevel = 100 group by trainerid, pokelevel;

#How many pokemon only belong to one trainer and no other
Select count(pokemon_id) as nr_trainers, pokemon_id from pokemon_trainer group by pokemon_id having count(pokemon_id) = 1;
13 changes: 13 additions & 0 deletions part4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#Directions: Write a query that returns the following collumns:

#Pokemon Name(pokemon) Trainer Name(trainer) Level (PT) Primary Type (pokemon) Secondary Type (pokemon)
#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.


Select t.trainername as trainer_name, p.name as pokemon_name, pt.pokelevel as level, p.primary_type as primary_type, p.secondary_type as secondary_type
from pokemons as p join pokemon_trainer as pt join trainers as t on p.id = pt.pokemon_id and t.trainerid = pt.trainerid
group by t.trainername, p.name, pt.pokelevel, p.primary_type, p.secondary_type
order by pt.pokelevel desc;
28,805 changes: 28,805 additions & 0 deletions pokemon_sql/pokemon_pokemon_trainer.sql

Large diffs are not rendered by default.

657 changes: 657 additions & 0 deletions pokemon_sql/pokemon_pokemons.sql

Large diffs are not rendered by default.

11,861 changes: 11,861 additions & 0 deletions pokemon_sql/pokemon_trainers.sql

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions pokemon_sql/pokemon_types.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
create table types(id int auto_increment primary key,name text not null);
INSERT INTO pokemon.types (id, name) VALUES (1, 'Normal');
INSERT INTO pokemon.types (id, name) VALUES (2, 'Water');
INSERT INTO pokemon.types (id, name) VALUES (3, 'Grass');
INSERT INTO pokemon.types (id, name) VALUES (4, 'Rock');
INSERT INTO pokemon.types (id, name) VALUES (5, 'Fire');
INSERT INTO pokemon.types (id, name) VALUES (6, 'Ground');
INSERT INTO pokemon.types (id, name) VALUES (7, 'Poison');
INSERT INTO pokemon.types (id, name) VALUES (8, 'Bug');
INSERT INTO pokemon.types (id, name) VALUES (9, 'Electric');
INSERT INTO pokemon.types (id, name) VALUES (10, 'Dragon');
INSERT INTO pokemon.types (id, name) VALUES (11, 'Steel');
INSERT INTO pokemon.types (id, name) VALUES (12, 'Dark');
INSERT INTO pokemon.types (id, name) VALUES (13, 'Fighting');
INSERT INTO pokemon.types (id, name) VALUES (14, 'Psychic');
INSERT INTO pokemon.types (id, name) VALUES (15, 'Ghost');
INSERT INTO pokemon.types (id, name) VALUES (16, 'Fairy');
INSERT INTO pokemon.types (id, name) VALUES (17, 'Ice');
INSERT INTO pokemon.types (id, name) VALUES (18, 'Flying');