strawquery PT
All lessons

Lesson 22 of 30

Counting and summing

Today at the studio

It is the quarterly meeting, and the questions have changed. "How many?" "How much in total?" "What is the average?" No one wants rows anymore, they want one number.

The idea

Aggregate functions turn many rows into one: COUNT(*) counts rows, SUM(x) adds, AVG(x) averages, MIN(x) and MAX(x) find the extremes.

COUNT(*) counts every row, while COUNT(column) counts only the rows where that column is not NULL. The other functions ignore NULL values too.

Example

SELECT COUNT(*), MAX(price) FROM merch

Your turn

0 of 4 questions

Question 1 of 4

How many shows does the studio have?

Unofficial fan project. Titles belong to their creators and rights holders.