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
Binary file added .DS_Store
Binary file not shown.
8 changes: 8 additions & 0 deletions pokemon_sql/Final Report.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Select p.name as 'Pokemon Name', t.trainername as 'Trainer Name', pt.pokelevel as
'Pokemon Level', t1.name as 'Primary Type', t2.name as 'Secondary Type'
from pokemon_trainer as pt
inner join pokemons as p on p.id = pt.pokemon_id
inner join trainers as t on t.trainerID = pt.trainerID
join types as t1 on t1.id = p.primary_type
join types as t2 on t2.id = p.secondary_type
order by pt.pokelevel desc;
10 changes: 10 additions & 0 deletions pokemon_sql/Pokemon Answers Part1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#What are all the types of pokemon that a pokemon can have?
Select distinct name 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(distinct name) from pokemons;
#How many types are there?
Select count(*) from types;
#How many pokemon have a secondary type?
Select count(*) from pokemons where secondary_type is not null;
21 changes: 21 additions & 0 deletions pokemon_sql/Pokemon Answers Part2.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#What is each pokemon's primary type?
Select p.name, t.name from pokemons as p join types as t on p.primary_type = t.id;
#What is Rufflet's secondary type?
Select p.name, t.name from pokemons as p join types as t on p.secondary_type = t.id Where p.name = 'Rufflet';
#What are the names of the pokemon that belong to the trainer with trainerID 303?
Select t.trainername, p.name as 'pokemon name'
from pokemon_trainer as pt
join trainers as t on t.trainerID = pt.trainerID
join pokemons as p on p.id = pt.pokemon_id;

#How many pokemon have a secondary type Poison
Select count(*) 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 t.name, count(*)
from pokemons as p
join types as t on p.primary_type = t.id
group by t.name;
#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

#How many pokemon only belong to one trainer and no other?
13 changes: 13 additions & 0 deletions pokemon_sql/pokemon_pokemon_trainer.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Select * From types;
Select * From pokemons;
Select name From pokemons order by id desc;
#What are all the types of pokemon that a pokemon can have?
Select distinct name 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(distinct name) from pokemons;
#How many types are there?
Select count(*) from types;
#How many pokemon have a secondary type?
Select count(*) from pokemons where secondary_type is not null;
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');