|
@@ -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
|