| 1234567891011121314151617 |
- Sort the data by finding out which trainer has the strongest pokemon so that this will act as a ranking of strongest to weakest trainer. You may interpret strongest in whatever way you want, but you will have to explain your decision.
-
- Explanation::
- I sorted by average pokemon level of each trainers. Then trainers with the same level, I sorted by who has the most pokemon. Following that, i sorted in alphabetical order.
-
- SELECT ANY_VALUE(pokemon.pokemons.name),
- pokemon.trainers.trainername,
- ANY_VALUE(pokemon.pokemon_trainer.pokelevel),
- ANY_VALUE(type1.name),
- ANY_VALUE(type2.name)
- FROM pokemon.pokemons
- CROSS JOIN pokemon.pokemon_trainer ON pokemon.pokemons.id = pokemon.pokemon_trainer.pokemon_id
- CROSS JOIN pokemon.trainers ON pokemon.trainers.trainerID = pokemon.pokemon_trainer.trainerID
- LEFT JOIN pokemon.types AS type1 ON pokemon.pokemons.primary_type = type1.id
- LEFT JOIN pokemon.types AS type2 ON pokemon.pokemons.secondary_type = type2.id
- GROUP BY pokemon.trainers.trainername
- ORDER BY AVG(pokemon.pokemon_trainer.pokelevel) DESC, COUNT(pokemon.trainers.trainername) DESC, pokemon.trainers.trainername
|