Aggregations Part 6

We’ve seen how to calculate individual aggregations, like the average or count of a number of rows. Let’s see how simple it is to combine these aggregations into 1 single SQL query, so we don’t have to have 5 different SQL queries.

SELECT AVG(2022 estimate), SUM(2022 estimate), COUNT(2022 estimate), MIN(2022 estimate), MAX(2022 estimate)

FROM database_table

WHERE ST = ‘CA’

  • Now the SQL statement will return 5 columns, and perform all 5 calculations together to return all data at once for simpler SQL querying.