From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Solution: Leverage window functions - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
Solution: Leverage window functions
(upbeat music) - [Narrator] For this challenge, we were asked to retrieve information about some energy efficient electrical products. I'm going to go ahead and start by running the sample query that we were given here to start, and that'll show us the data that we have to work with. Now for this challenge, we're going to need to return all of these columns, so the product name, category, and price data. So I'm just going to leave everything as is here in the answer to have a comma at the end of line six, and come down to line number seven. Then in the challenge, we were asked to get some statistical information about the products that are in the same category for each row. And one of the things we were asked for was for the minimum price in the category. So I'll go ahead and type in our min function, price. Now, if I leave it just like this, it's going to calculate the minimum price across the entire data set, which is not what I want. For this first row in the results, which is in…
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
-
-
-
-
Create a window function with an OVER clause4m 11s
-
(Locked)
Partition rows within a window4m 7s
-
(Locked)
Streamline partition queries with a WINDOW clause2m 42s
-
(Locked)
Ordering data within a partition5m 8s
-
(Locked)
Calculate a moving average with a sliding window4m 52s
-
(Locked)
Return values at specific locations within a window7m 53s
-
(Locked)
Solution: Leverage window functions4m 41s
-
-
-
-
-
-