Skip to content

Instantly share code, notes, and snippets.

@CatTrinket
Created August 11, 2014 19:20
Show Gist options
  • Save CatTrinket/439662b3bccceecbf492 to your computer and use it in GitHub Desktop.
Save CatTrinket/439662b3bccceecbf492 to your computer and use it in GitHub Desktop.
how many species of each type (so e.g. Rotom counts once for Electric, once for Ghost, once for Fire...)
asb_test=> select t.name, count(distinct pf.species_id) from types t
asb_test-> join pokemon_form_types pft on t.id=pft.type_id
asb_test-> join pokemon_forms pf on pft.pokemon_form_id=pf.id
asb_test-> group by t.id
asb_test-> order by count desc;
name | count
----------+-------
Water | 120
Normal | 97
Flying | 94
Grass | 86
Psychic | 75
Bug | 67
Ground | 62
Poison | 60
Fire | 58
Rock | 56
Fighting | 47
Dark | 46
Electric | 43
Steel | 43
Dragon | 41
Fairy | 36
Ice | 36
Ghost | 35
(18 rows)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment