From the course: SQL for Exploratory Data Analysis Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Partitioning data

Partitioning data - PostgreSQL Tutorial

From the course: SQL for Exploratory Data Analysis Essential Training

Start my 1-month free trial

Partitioning data

- [Instructor] Now we're gonna talk about partitioning data. When working with histograms, we need to group data into buckets. Let's consider ages again. We want to group the five, six, seven, eight, and nine-year-olds all into one bucket. We can do that by dividing the age by the width of the bucket we are using. In our case, the bucket width is five, so when we do the division, we get these results. You'll notice that all of the results are between one and two. We really aren't interested in the decimal or fractional part of the number. We wanna group according to the whole number part of the result. We can do this using the FLOOR function. The FLOOR function drops the decimal part of a number and returns the whole number part. We can do this operation all in one step by combining the division and the FLOOR operation. We can see this works for other buckets too like the 10 to 14-year-old bucket. Then applying the FLOOR function, we have the value of two as the corresponding bucket…

Contents