Browse Source

updating the answer files

Whitney Martinez 5 years ago
parent
commit
cc022b90a7
2 changed files with 113 additions and 0 deletions
  1. 82
    0
      pokemon_sql/Answers.sql
  2. 31
    0
      pokemon_sql/Final Answers.sql

+ 82
- 0
pokemon_sql/Answers.sql View File

@@ -0,0 +1,82 @@
1
+
2
+#What are all the types of pokemon that a pokemon can have?
3
+SELECT COUNT(ID)
4
+FROM pokemon.types;
5
+
6
+#What is the name of the pokemon with id 45?
7
+SELECT name
8
+FROM pokemon.types
9
+WHERE id;
10
+
11
+#How many pokemon are there?
12
+SELECT ID,NAME
13
+FROM pokemon.pokemons
14
+WHERE id IN (45);
15
+
16
+#How many types are there?
17
+SELECT COUNT(ID)
18
+FROM pokemon.pokemons
19
+WHERE id;
20
+
21
+#How many pokemon have a secondary type?
22
+SELECT COUNT(ID)
23
+FROM pokemon.pokemons
24
+WHERE secondary_type IS NOT NULL;
25
+
26
+
27
+#What is each pokemon's primary type?
28
+SELECT DISTINCT pokemons.name,types.name
29
+FROM pokemon.pokemons
30
+       inner join pokemon.types on types.id = primary_type;
31
+
32
+
33
+#What is Rufflet's secondary type?
34
+SELECT DISTINCT pokemons.name,types.name
35
+FROM pokemon.pokemons
36
+       inner join pokemon.types on types.id = secondary_type
37
+WHERE pokemons.name LIKE 'Rufflet';
38
+
39
+
40
+#What are the names of the pokemon that belong to the trainer with trainerID 303?
41
+SELECT pokemon.pokemons.name, pokemon.pokemon_trainer.trainerID
42
+FROM pokemon.pokemons
43
+       inner join pokemon.pokemon_trainer on trainerID
44
+WHERE trainerID LIKE 303;
45
+
46
+
47
+#How many pokemon have a secondary type Poison
48
+SELECT COUNT(pokemon.pokemons.secondary_type)
49
+FROM pokemon.pokemons
50
+       inner join pokemon.types on types.id = secondary_type
51
+WHERE types.name LIKE 'Poison';
52
+
53
+
54
+#What are all the primary types
55
+SELECT pokemon.types.name,pokemon.pokemons.primary_type
56
+from pokemon.types
57
+       inner join pokemon.pokemons;
58
+
59
+
60
+#and how many pokemon have that type?
61
+SELECT pokemon.types.name, COUNT(pokemon.pokemons.id)
62
+FROM pokemon.pokemons
63
+       JOIN pokemon.types
64
+         ON pokemons.primary_type = types.id
65
+GROUP BY types.id;
66
+
67
+
68
+#How many pokemon at level 100 does each trainer with at least one level 100 pokemone have?
69
+SELECT pokemon_trainer.trainerID, COUNT(pokemon_trainer.pokelevel)
70
+FROM pokemon.pokemon_trainer
71
+WHERE pokelevel LIKE 100
72
+GROUP BY trainerID;
73
+
74
+
75
+#How many pokemon only belong to one trainer and no other?
76
+SELECT COUNT(*) AS "Legendaries"
77
+FROM (SELECT DISTINCT pokemon_id, COUNT(pokemon_id)
78
+FROM pokemon_trainer
79
+GROUP BY pokemon_idmaxhp
80
+HAVING COUNT(DISTINCT trainerID) = 1) alias ;
81
+
82
+use pokemon

+ 31
- 0
pokemon_sql/Final Answers.sql View File

@@ -0,0 +1,31 @@
1
+#Dragons, at least in the earlier Gens they were pretty OP with barely no weaknesses and a large move pool, before them was psychic.
2
+#Honestly if there were natures, EV's and IV's going on there would be a more complex list and I will go on a tangent about pokemon so I'll stop myself
3
+#now and just go with Dragons most have high stats in almost every field and you can negate some of their weaknesses. Dragon are x2 weak against themselves but
4
+#it's a fair fight there but if you got one with strudy or Focus Sash/ Focus band along with leftovers your monster can cause major damage to opponents.
5
+# Always good to have at least 1 dragon in your team. https://i.imgflip.com/2m5b5f.jpg
6
+
7
+SELECT pk.name as "Pokemon Name", trainername as "Trainer Names",primary_type as "1st Type", t2.pokelevel as "Lvl",
8
+       t2.attack as "Attack", t2.defense as "Defense", t2.speed as "Speed"
9
+from pokemon.pokemon_trainer t2
10
+       left join pokemon.trainers t on t.trainerID = t2.trainerID
11
+       left join pokemon.pokemons pk on t2.pokemon_id = pk.id
12
+       left join pokemon.types ptyp on ptyp.id = pk.primary_type
13
+       left join pokemon.types styp on pk.secondary_type = styp.id
14
+WHERE ptyp.name LIKE 'Dragon'
15
+ORDER BY Defense DESC;
16
+
17
+
18
+# WITH THAT SAID THO, Ghost types are my shit. I love them. They're morbid and their description always pushes that E rating
19
+# Also my fave artist Junji ito made some cool draws of them so overall they're just great. Go team Ghost!
20
+
21
+SELECT pk.name as "Pokemon Name", trainername as "Trainer Names",primary_type as "1st Type", t2.pokelevel as "Lvl",
22
+t2.attack as "Attack", t2.defense as "Defense", t2.speed as "Speed"
23
+from pokemon.pokemon_trainer t2
24
+left join pokemon.trainers t on t.trainerID = t2.trainerID
25
+left join pokemon.pokemons pk on t2.pokemon_id = pk.id
26
+left join pokemon.types ptyp on ptyp.id = pk.primary_type
27
+left join pokemon.types styp on pk.secondary_type = styp.id
28
+WHERE ptyp.name LIKE 'Ghost'
29
+ORDER BY Speed DESC;
30
+
31
+use pokemon