From the course: PostgreSQL: Advanced Queries

Unlock the full course today

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

Calculate the first and third quartiles of a dataset

Calculate the first and third quartiles of a dataset - PostgreSQL Tutorial

From the course: PostgreSQL: Advanced Queries

Calculate the first and third quartiles of a dataset

- [Instructor] The percentile function that we used to calculate the median value of a dataset can be also used to find other division points. For instance, a statistical analysis may require that you split the data into four groups called quartiles. The value where a data point transitions between the first, second, third, and fourth quartiles can be determined using the same percentile functions. Let's take another look at our height data. And because our dataset has an even number of rows, I'm going to be sticking with the continuous percentile functions. So I'll select the percentile_cont, and inside of the parentheses we previously used 0.5 to denote the value 50% of the way through the sorted list of values. But we can put whatever percentage we want in here. To find the break point where a row would transition from the first to second quartile, put 0.25. Then we can finish out the function. Within group we'll order…

Contents