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 - 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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
Using GROUP BY to aggregate data rows7m 9s
-
(Locked)
Obtain general-purpose aggregate statistics5m 16s
-
(Locked)
Evaluate columns with Boolean aggregates4m 37s
-
(Locked)
Find the standard deviation and variance of a dataset5m 18s
-
Include overall aggregates with ROLLUP4m 14s
-
Return all possible combinations of groups with CUBE3m 38s
-
(Locked)
Segmenting groups with aggregate filters4m 57s
-
(Locked)
Solution: Group statistics with filters5m 7s
-
-
-
-
-
-
-