Lesson 8 of 22 · SQLite

Aggregate Functions

Count, sum and average data with SQL aggregate functions and GROUP BY.

Aggregate functions compute a single result from a set of values.

FunctionDescription
COUNT()Number of rows
SUM()Total of numeric column
AVG()Average value
MIN()Minimum value
MAX()Maximum value

GROUP BY

SELECT city, COUNT(*) as total
FROM crime_scene_report GROUP BY city;

Your challenge

Count the crime reports in each city. Return two columns: the city and its number of reports.

Solve it in your browser

Free, no sign-up. The SQLite database runs in your browser; your answer is checked instantly, with hints if you need them. Plus a 2-question quiz.