From the course: PostgreSQL: Advanced Queries
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
View top performers with percentile ranks - PostgreSQL Tutorial
From the course: PostgreSQL: Advanced Queries
View top performers with percentile ranks
- [Instructor] In the previous chapter, we looked at calculating the values that define the breaks between different percentiles and quartiles. We also looked at end tile window function that divided our data into equal groups. But we saw that it really wasn't suitable for determining usable statistical quartiles in line with the data. In order to break our dataset into usable quartiles, we first need to use a percentile ranking function. This will reveal the percentage of rows that are above the current row in a stack rank. I'll start by selecting the name, gender, and height columns from the people_heights table. Then we'll add another column to the output. For this, I'll use the percent_rank function. The over clause will create a window frame for my data. Now, I don't need to partition it, but I do need to sort it, based off of the height_inches descending. This will calculate the percentage rank for each row in my…
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.