Aggregation

Using built-in statistical functions

Aggregate functions are used to perform some kind of mathematical or statistical calculation across a group of rows. The rows in each group are determined by the different values in a specified column or columns. Alternatively you can aggregate across the entire table.

If we wanted to know the minimum, average and maximum dates of birth (birth_date) across the whole employees table we could write a query such as this;

SELECT 
    min(birth_date),
    avg(birth_date),
    max(birth_date)
FROM employees;

This sort of query provides us with a general view of the values for a particular column or field across the whole table.

Another useful function is count. This can be used to return a total of records corresponding to a particular condition. e.g How many employees are female.

select count(*) from employees  where gender = 'F';

count, min , max and avg are built in aggregate functions in SQLite (and any other SQL database system). There are other such functions avaialable. A complete list can be found in the SQLite documentation here