Today I Learned

hashrocket A Hashrocket project

Count Records By Type

If you have a table with some sort of type column on it, you can come up with a count of the records in that table by type. You just need to take advantage of group by:

> select type, count(*) from pokemon group by type;

  type   | count 
 fire    |    10
 water   |     4
 plant   |     7
 psychic |     3
 rock    |    12
See More #sql TILs
Looking for help? Hashrocket developers believe that data quality is as important as code quality. We enjoy all the challenges of relational databases, from finding the fastest index, to structuring data to fit the needs of an application. We're eager to share our experiences; check out PG Casts, our series of free PostgreSQL screencasts.