Aggregations Part 1 — COUNT()

The COUNT() aggregation returns how many rows are in a dataset — a very useful way to quickly gauge how big a dataset is, and can also be used in calculations later on. Let’s see how many California cities are in the top 23 US cities by population on the right:

SELECT COUNT(*)

FROM database_table

WHERE ST = ‘CA’

  • The number 4 will be returned (since Los Angeles, San Diego, San Jose, and San Francisco all fulfill the condition ST = ‘CA’ )