select P.name as "Pokemon", T.name as "Type"
from pokemon.pokemons p
JOIN pokemon.types T
ON p.primary_type = T.id;

select P.name as "Pokemon", T.name as "Type"
from pokemon.pokemons p
JOIN pokemon.types T
ON p.primary_type = T.id
WHERE P.name = 'Rufflet';

select T.trainername as "Trainer", P.name as "Pokemon"
from pokemon.pokemons P
Join pokemon.pokemon_trainer PT on PT.pokemon_id = P.id
join pokemon.trainers T on PT.trainerID = T.trainerID
where T.trainerID = 303;

select P.name as "Pokemon", T.name as "Type"
from pokemon.pokemons p
JOIN pokemon.types T
ON p.secondary_type = T.id
where T.name = 'Poison';

select T.name as "Primary Types", count(P.id)
from pokemon.pokemons p
JOIN pokemon.types T
ON p.primary_type = T.id
group by T.id;

SELECT T.trainername as "Trainer ID", COUNT(PT.pokelevel) as "# of Lvl 100 Pokemon"
FROM pokemon.pokemon_trainer PT
JOIN pokemon.trainers T
ON T.trainerID = PT.trainerID
WHERE PT.pokelevel = 100
GROUP BY PT.trainerID;

CREATE TABLE pokemon.one_pokemon(SELECT pokemon_id, count(pokemon_id)
FROM pokemon.pokemon_trainer
GROUP BY pokemon_id
HAVING count(DISTINCT trainerID) = 1);

SELECT count(one_pokemon.pokemon_id)
from pokemon.one_pokemon;
