Skip to content

Latest commit

 

History

History
33 lines (24 loc) · 712 Bytes

count-how-many-records-in-each-category.md

File metadata and controls

33 lines (24 loc) · 712 Bytes

How to Count How Many Records Are In Each Category


You can get the count of how many records there are in each "category" in a table by using group by:

> select species, count(*) from animals group by species;
species count
bird 140
mammal 430
reptile 200
fish 750

link

You can also optionally sort the output in descending order.

> select species, count(*) from animals group by species order by count;
species count
fish 750
mammal 430
reptile 200
bird 140

link