From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Solution: Evaluate rankings within a dataset - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
Solution: Evaluate rankings within a dataset
(upbeat music) - [Instructor] In this code challenge, we were asked to rank our products by pricing in three different ways. The first one is to get an overall ranking across the entire product line. The second is to rank products within the same category. And finally, we want a ranking of products within the same size classifications. So let's get started by running the starting select query to see the source data. Now, this is a smaller set of products than what we've seen in other places in this course. We can see we have some olive oils, some flavor infused oils, as well as some bath and beauty products to work with. Okay, let's go back to the challenge over here on the right. I'm going to start with the four columns of the original data, type a comma here after price, and I'll come down to line number eight. Here, we can begin ranking our products. Now, the challenge asked for dense rankings. So I'm going to type in the dense rank function here in an open and closed parentheses…
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.