From the course: Introduction to SQLite

Unlock this course with a free trial

Join today to access over 25,500 courses taught by industry experts.

Aggregate functions

Aggregate functions

- [Instructor] Earlier, you saw how to use the GROUP BY clause with the sum and count functions. These are examples of aggregate functions as shown here on the SQLite.org documentation page. Let's take a look at these and other functions in more detail. You can use the count function to count the number of values. In the first form, you're counting the number of rows. However, in the second form, you're counting the number of non null values for a given value, in this case, the billing postal code column. The results are different because there are a number of invoices without postal codes. You can also count the number of unique items by using the distinct keyword. This shows us all the unique postal codes in the invoice table. What if we wanted to answer a somewhat complex question, such as what is the average number of customers per country? Well, we'd start with something like this. This will give us the number of…

Contents