This repository was archived by the owner on Feb 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPokemon Queries Script.sql
More file actions
54 lines (42 loc) · 2.24 KB
/
Copy pathPokemon Queries Script.sql
File metadata and controls
54 lines (42 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#Basic inner join with the Pokemon's characteristics and st
SELECT p.`Name`, p.`National Number`, p.`Regional Number`, bs.`HP`
FROM Pokemon p
INNER JOIN `Base Stats`bs ON bs.`National Number` = p.`National Number`;
#WHERE and ORDER BY clauses. Shows Top 6 Pokemon with high HP and their basic characteristics
SELECT Pokemon.`National Number`, Pokemon.Name, `Base Stats`.HP
FROM Pokemon
JOIN `Base Stats` ON Pokemon.`National Number` = `Base Stats`.`National Number`
WHERE `Base Stats`.HP > 150
ORDER BY `Base Stats`.Speed DESC LIMIT 6;
#best special attackers
SELECT p.`National Number`, p.`Name`, bs.`Attack`, bs.`Special Attack` FROM Pokemon p
JOIN `Base Stats` bs ON p.`National Number` = bs.`National Number`
WHERE `Special Attack` > `Attack`
ORDER BY `Special Attack` DESC;
#Multiple joins, shows Pokemon and moves
#Future potential for a stored function showing all moves in one row
SELECT p.`National Number`, p.Name, m.`Move Name` FROM `Pokemon Moves` pm
JOIN Pokemon p ON pm.`National Number` = p.`National Number`
JOIN Moves m ON m.`Move ID` = pm.`Move ID`
ORDER BY p.`National Number` ASC;
#This shows type effectiveness for water types. Where no type is matched, assume normal damage
SELECT `Type Damage`.`Damage Multiplier`, `Type`.`Type Name`
FROM `Type Damage`
JOIN `Type` ON `Type Damage`.`Damaged Type ID` = `Type`.`Type ID`
WHERE `Attacker Type ID` = 12;
#Demonstrates GROUP BY and HAVING, also showing underrepresentation of ghost types
SELECT p.`National Number`, p.`Name`, t.`Type Name`
FROM `Pokemon` p
JOIN `Pokemon Types` pt ON p.`National Number` = pt.`National Number`
JOIN `Type`t ON pt.`Type ID` = t.`Type ID`
JOIN `Base Stats` bs ON p.`National Number` = bs.`National Number`
GROUP BY p.`National Number`
HAVING t.`Type Name` = 'Ghost';
#Multi-table query showing off how many tables we can use at once
SELECT p.`National Number`, p.`Name`, t.`Type Name`, bs.`HP`, bs.`Attack`, bs.`Defence`,
bs.`Special Attack`, bs.`Special Defence`, bs.`Speed`
FROM `Pokemon` p
JOIN `Pokemon Types` pt ON p.`National Number` = pt.`National Number`
JOIN `Type` t ON pt.`Type ID` = t.`Type ID`
JOIN `Base Stats` bs ON p.`National Number` = bs.`National Number`
ORDER BY p.`National Number`;