From the course: PostgreSQL: Advanced Queries

Unlock the full course today

Join today to access over 24,400 courses taught by industry experts.

Obtain general-purpose aggregate statistics

Obtain general-purpose aggregate statistics - PostgreSQL Tutorial

From the course: PostgreSQL: Advanced Queries

Obtain general-purpose aggregate statistics

- [Instructor] Once we have individual data rows collected into buckets with the group by clause, we can start to perform some statistical analyses within those groups. We've already seen how to count up the number of rows within a group with the count function. There are a number of additional functions that operate in the same way. Let's start by taking a look at our products and their prices. We'll execute a query that selects the sku, product name, size, and price columns from inventory.products. This returns a row for all 114 products in inventory. Each of the different olive oil products are available in multiple sizes and at different prices. We can use a group by query to combine all of this data based off of the type of oil, and then perform some aggregate calculations to get a better feel for the range of prices for each oil type. We'll start by writing out the group by query with the counting function that we…

Contents