From the course: PostgreSQL: Advanced Queries

Unlock the full course today

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

Solution: Retrieve statistics of a dataset with groups

Solution: Retrieve statistics of a dataset with groups - PostgreSQL Tutorial

From the course: PostgreSQL: Advanced Queries

Solution: Retrieve statistics of a dataset with groups

(cheerful music) - [Presenter] In this code challenge, we were asked to retrieve some statistical data about product pricing, and specifically, were to retrieve the minimum price first, second, and third quartile prices, the maximum price, as well as the price range within each product category. I'll start by running the sample query here that we have the starting select statement. We'll test the code here and that'll give us the data that we have to work with. Here, we have a number of olive oil products and they're categorized as olive oils. And if I scroll down here, I'll see we also have some flavor infused oils, and there's actually a bath and beauty category as well that we'll see in just a moment. Now actually what I want to do here is just change this to a select distinct query, and we'll just take a look at the category column by itself. So we'll get rid of price here and get rid of that comma. Let me test the code again. And that gives me the three categories I can see. So…

Contents