From the course: PostgreSQL: Advanced Queries

Unlock the full course today

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

Determine the range of values within a dataset

Determine the range of values within a dataset - PostgreSQL Tutorial

From the course: PostgreSQL: Advanced Queries

Determine the range of values within a dataset

- [Narrator] The range of a dataset is the last statistical measurement of central tendency that we have yet to look at. But truth be told, this is just a simple subtraction calculation, and there's no PostgreSQL function to calculate this value. I'm simply including this movie for completeness sake. To calculate the range of a dataset, all we need to do is subtract the minimum value from the maximum value. So to find the range of our height data, we could write out the query like this. It would say select, use the max function against the height inches column, and we'll subtract the min function, applied to the height inches column. That completes the calculation. Let's give it an alias, I'll call it height range, and we'll pull the data from the public dot people heights table. So that's all there is to the range calculation. I'll execute the query, and it tells me that my data has a range of 19 and a half inches.…

Contents