Understand how to calculate histograms in SQL.
- [Instructor] Now that we know how to partition data,…let's calculate histograms.…We want to list the bucket_floor…and the average cost of insuring a person in each bucket.…Let's start by creating a select statement.…With the bucket logic from the previous lesson…on creating partitions or buckets,…we know that we can use this SQL statement…to create bucket_floors for each age.…Since we don't need the buckets enumerated,…we can remove the bucket calculation…and keep just the bucket_floor.…The next thing we want to do is average the cost…of insuring each person.…
Assuming the cost of each person is in the column,…annual insurance, we'll add AVG(annual_cost).…Since average is an aggregate function,…and we want to get the averages for subsets…of the whole table, we'll need to have a group by clause.…So let's add that too,…and to make sure the results are listed in increasing order,…we can order by Bucket_floor.…So the final statement includes selecting two values,…the bucket_floor and the average annual cost,…and we group by the bucket_floor, and we order…
Released
6/7/2018- Exploratory data analysis vs. hypothesis-driven statistical analysis
- Performing data quality checks
- Calculating quartiles
- Using box plot to understand the distribution of values
- Using histograms to understand the frequency of values
- Using chi square to understand the correlation between values
Share this video
Embed this video
Video: Calculating histograms